配置:

    1. jenkins:
    2. mode: EXCLUSIVE
    3. numExecutors: 5
    4. scmCheckoutRetryCount: 2
    5. clouds:
    6. - kubernetes:
    7. name: "kubernetes"
    8. serverUrl: "https://kubernetes.default"
    9. skipTlsVerify: true
    10. namespace: "kubesphere-devops-system"
    11. credentialsId: "k8s-service-account"
    12. jenkinsUrl: "http://ks-jenkins.kubesphere-devops-system:80"
    13. jenkinsTunnel: "ks-jenkins-agent.kubesphere-devops-system:50000"
    14. containerCapStr: "100"
    15. connectTimeout: "60"
    16. readTimeout: "60"
    17. maxRequestsPerHostStr: "32"
    18. templates:
    19. - name: "base"
    20. namespace: "kubesphere-devops-system"
    21. label: "base"
    22. nodeUsageMode: "NORMAL"
    23. idleMinutes: 0
    24. containers:
    25. - name: "base"
    26. image: "kubesphere/builder-base:v3.1.0"
    27. command: "cat"
    28. args: ""
    29. ttyEnabled: true
    30. resourceRequestCpu: "100m"
    31. resourceLimitCpu: "4000m"
    32. resourceRequestMemory: "100Mi"
    33. resourceLimitMemory: "8192Mi"
    34. - name: "jnlp"
    35. image: "jenkins/jnlp-slave:3.27-1"
    36. command: "jenkins-slave"
    37. args: "^${computer.jnlpmac} ^${computer.name}"
    38. resourceRequestCpu: "50m"
    39. resourceRequestMemory: "400Mi"
    40. resourceLimitMemory: "1536Mi"
    41. workspaceVolume:
    42. emptyDirWorkspaceVolume:
    43. memory: false
    44. volumes:
    45. - hostPathVolume:
    46. hostPath: "/var/run/docker.sock"
    47. mountPath: "/var/run/docker.sock"
    48. - hostPathVolume:
    49. hostPath: "/var/data/jenkins_sonar_cache"
    50. mountPath: "/root/.sonar/cache"
    51. yaml: "spec:\r\n affinity:\r\n nodeAffinity:\r\n preferredDuringSchedulingIgnoredDuringExecution:\r\n - weight: 1\r\n preference:\r\n matchExpressions:\r\n - key: node-role.kubernetes.io/worker\r\n operator: In\r\n values:\r\n - ci\r\n tolerations:\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"NoSchedule\"\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"PreferNoSchedule\"\r\n containers:\r\n - name: \"base\"\r\n resources:\r\n requests:\r\n ephemeral-storage: \"1Gi\"\r\n limits:\r\n ephemeral-storage: \"10Gi\"\r\n securityContext:\r\n fsGroup: 1000\r\n "
    52. - name: "nodejs"
    53. namespace: "kubesphere-devops-system"
    54. label: "nodejs"
    55. nodeUsageMode: "EXCLUSIVE"
    56. idleMinutes: 0
    57. containers:
    58. - name: "nodejs"
    59. image: "kubesphere/builder-nodejs:v3.1.0"
    60. command: "cat"
    61. args: ""
    62. ttyEnabled: true
    63. resourceRequestCpu: "100m"
    64. resourceLimitCpu: "4000m"
    65. resourceRequestMemory: "100Mi"
    66. resourceLimitMemory: "8192Mi"
    67. - name: "jnlp"
    68. image: "jenkins/jnlp-slave:3.27-1"
    69. command: "jenkins-slave"
    70. args: "^${computer.jnlpmac} ^${computer.name}"
    71. resourceRequestCpu: "50m"
    72. resourceRequestMemory: "400Mi"
    73. resourceLimitMemory: "1536Mi"
    74. workspaceVolume:
    75. emptyDirWorkspaceVolume:
    76. memory: false
    77. volumes:
    78. - hostPathVolume:
    79. hostPath: "/var/run/docker.sock"
    80. mountPath: "/var/run/docker.sock"
    81. - hostPathVolume:
    82. hostPath: "/var/data/jenkins_nodejs_yarn_cache"
    83. mountPath: "/root/.yarn"
    84. - hostPathVolume:
    85. hostPath: "/var/data/jenkins_nodejs_npm_cache"
    86. mountPath: "/root/.npm"
    87. - hostPathVolume:
    88. hostPath: "/var/data/jenkins_sonar_cache"
    89. mountPath: "/root/.sonar/cache"
    90. yaml: "spec:\r\n affinity:\r\n nodeAffinity:\r\n preferredDuringSchedulingIgnoredDuringExecution:\r\n - weight: 1\r\n preference:\r\n matchExpressions:\r\n - key: node-role.kubernetes.io/worker\r\n operator: In\r\n values:\r\n - ci\r\n tolerations:\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"NoSchedule\"\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"PreferNoSchedule\"\r\n containers:\r\n - name: \"nodejs\"\r\n resources:\r\n requests:\r\n ephemeral-storage: \"1Gi\"\r\n limits:\r\n ephemeral-storage: \"10Gi\"\r\n securityContext:\r\n fsGroup: 1000\r\n "
    91. - name: "nodejs-14.8.0"
    92. namespace: "kubesphere-devops-system"
    93. label: "nodejs-14.8.0"
    94. nodeUsageMode: "EXCLUSIVE"
    95. idleMinutes: 0
    96. containers:
    97. - name: "nodejs"
    98. image: "bytest-harbor.ur.com.cn/base-image/nodejs:14.8.0"
    99. command: "cat"
    100. args: ""
    101. ttyEnabled: true
    102. resourceRequestCpu: "100m"
    103. resourceLimitCpu: "4000m"
    104. resourceRequestMemory: "100Mi"
    105. resourceLimitMemory: "8192Mi"
    106. - name: "jnlp"
    107. image: "jenkins/jnlp-slave:3.27-1"
    108. command: "jenkins-slave"
    109. args: "^${computer.jnlpmac} ^${computer.name}"
    110. resourceRequestCpu: "50m"
    111. resourceRequestMemory: "400Mi"
    112. resourceLimitMemory: "1536Mi"
    113. workspaceVolume:
    114. emptyDirWorkspaceVolume:
    115. memory: false
    116. volumes:
    117. - hostPathVolume:
    118. hostPath: "/var/run/docker.sock"
    119. mountPath: "/var/run/docker.sock"
    120. - hostPathVolume:
    121. hostPath: "/var/data/jenkins_nodejs_yarn_cache"
    122. mountPath: "/root/.yarn"
    123. - hostPathVolume:
    124. hostPath: "/var/data/jenkins_nodejs_npm_cache"
    125. mountPath: "/root/.npm"
    126. - hostPathVolume:
    127. hostPath: "/var/data/jenkins_sonar_cache"
    128. mountPath: "/root/.sonar/cache"
    129. yaml: "spec:\r\n affinity:\r\n nodeAffinity:\r\n preferredDuringSchedulingIgnoredDuringExecution:\r\n - weight: 1\r\n preference:\r\n matchExpressions:\r\n - key: node-role.kubernetes.io/worker\r\n operator: In\r\n values:\r\n - ci\r\n tolerations:\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"NoSchedule\"\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"PreferNoSchedule\"\r\n containers:\r\n - name: \"nodejs\"\r\n resources:\r\n requests:\r\n ephemeral-storage: \"1Gi\"\r\n limits:\r\n ephemeral-storage: \"10Gi\"\r\n securityContext:\r\n fsGroup: 1000\r\n "
    130. - name: "nodejs-14.19.0"
    131. namespace: "kubesphere-devops-system"
    132. label: "nodejs-14.19.0"
    133. nodeUsageMode: "EXCLUSIVE"
    134. idleMinutes: 0
    135. containers:
    136. - name: "nodejs"
    137. image: "bytest-harbor.ur.com.cn/base-image/node:14.19.1"
    138. command: "cat"
    139. args: ""
    140. ttyEnabled: true
    141. resourceRequestCpu: "100m"
    142. resourceLimitCpu: "4000m"
    143. resourceRequestMemory: "100Mi"
    144. resourceLimitMemory: "8192Mi"
    145. - name: "jnlp"
    146. image: "jenkins/jnlp-slave:3.27-1"
    147. command: "jenkins-slave"
    148. args: "^${computer.jnlpmac} ^${computer.name}"
    149. resourceRequestCpu: "50m"
    150. resourceRequestMemory: "400Mi"
    151. resourceLimitMemory: "1536Mi"
    152. workspaceVolume:
    153. emptyDirWorkspaceVolume:
    154. memory: false
    155. volumes:
    156. - hostPathVolume:
    157. hostPath: "/var/run/docker.sock"
    158. mountPath: "/var/run/docker.sock"
    159. - hostPathVolume:
    160. hostPath: "/var/data/jenkins_nodejs_yarn_cache"
    161. mountPath: "/root/.yarn"
    162. - hostPathVolume:
    163. hostPath: "/var/data/jenkins_nodejs_npm_cache"
    164. mountPath: "/root/.npm"
    165. - hostPathVolume:
    166. hostPath: "/var/data/jenkins_nodejs_pnpm_cache"
    167. mountPath: "/home/jenkins/agent/.pnpm-store"
    168. - hostPathVolume:
    169. hostPath: "/var/data/jenkins_sonar_cache"
    170. mountPath: "/root/.sonar/cache"
    171. yaml: "spec:\r\n affinity:\r\n nodeAffinity:\r\n preferredDuringSchedulingIgnoredDuringExecution:\r\n - weight: 1\r\n preference:\r\n matchExpressions:\r\n - key: node-role.kubernetes.io/worker\r\n operator: In\r\n values:\r\n - ci\r\n tolerations:\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"NoSchedule\"\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"PreferNoSchedule\"\r\n containers:\r\n - name: \"nodejs\"\r\n resources:\r\n requests:\r\n ephemeral-storage: \"1Gi\"\r\n limits:\r\n ephemeral-storage: \"10Gi\"\r\n securityContext:\r\n fsGroup: 1000\r\n "
    172. - name: "maven"
    173. namespace: "kubesphere-devops-system"
    174. label: "maven"
    175. nodeUsageMode: "EXCLUSIVE"
    176. idleMinutes: 0
    177. containers:
    178. - name: "maven"
    179. image: "kubesphere/builder-maven:v3.1.0"
    180. command: "cat"
    181. args: ""
    182. ttyEnabled: true
    183. resourceRequestCpu: "100m"
    184. resourceLimitCpu: "4000m"
    185. resourceRequestMemory: "100Mi"
    186. resourceLimitMemory: "8192Mi"
    187. - name: "jnlp"
    188. image: "jenkins/jnlp-slave:3.27-1"
    189. command: "jenkins-slave"
    190. args: "^${computer.jnlpmac} ^${computer.name}"
    191. resourceRequestCpu: "50m"
    192. resourceRequestMemory: "400Mi"
    193. resourceLimitMemory: "1536Mi"
    194. workspaceVolume:
    195. emptyDirWorkspaceVolume:
    196. memory: false
    197. volumes:
    198. - hostPathVolume:
    199. hostPath: "/var/run/docker.sock"
    200. mountPath: "/var/run/docker.sock"
    201. - hostPathVolume:
    202. hostPath: "/var/data/jenkins_maven_cache"
    203. mountPath: "/root/.m2"
    204. - hostPathVolume:
    205. hostPath: "/var/data/jenkins_sonar_cache"
    206. mountPath: "/root/.sonar/cache"
    207. yaml: "spec:\r\n affinity:\r\n nodeAffinity:\r\n preferredDuringSchedulingIgnoredDuringExecution:\r\n - weight: 1\r\n preference:\r\n matchExpressions:\r\n - key: node-role.kubernetes.io/worker\r\n operator: In\r\n values:\r\n - ci\r\n tolerations:\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"NoSchedule\"\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"PreferNoSchedule\"\r\n containers:\r\n - name: \"maven\"\r\n resources:\r\n requests:\r\n ephemeral-storage: \"1Gi\"\r\n limits:\r\n ephemeral-storage: \"10Gi\"\r\n volumeMounts:\r\n - name: config-volume\r\n mountPath: /opt/apache-maven-3.5.3/conf/settings.xml\r\n subPath: settings.xml\r\n volumes:\r\n - name: config-volume\r\n configMap:\r\n name: ks-devops-agent\r\n items:\r\n - key: MavenSetting\r\n path: settings.xml\r\n securityContext:\r\n fsGroup: 1000\r\n "
    208. - name: "go"
    209. namespace: "kubesphere-devops-system"
    210. label: "go"
    211. nodeUsageMode: "EXCLUSIVE"
    212. idleMinutes: 0
    213. containers:
    214. - name: "go"
    215. image: "kubesphere/builder-go:v3.1.0"
    216. command: "cat"
    217. args: ""
    218. ttyEnabled: true
    219. resourceRequestCpu: "100m"
    220. resourceLimitCpu: "4000m"
    221. resourceRequestMemory: "100Mi"
    222. resourceLimitMemory: "8192Mi"
    223. - name: "jnlp"
    224. image: "jenkins/jnlp-slave:3.27-1"
    225. command: "jenkins-slave"
    226. args: "^${computer.jnlpmac} ^${computer.name}"
    227. resourceRequestCpu: "50m"
    228. resourceRequestMemory: "400Mi"
    229. resourceLimitMemory: "1536Mi"
    230. workspaceVolume:
    231. emptyDirWorkspaceVolume:
    232. memory: false
    233. volumes:
    234. - hostPathVolume:
    235. hostPath: "/var/run/docker.sock"
    236. mountPath: "/var/run/docker.sock"
    237. - hostPathVolume:
    238. hostPath: "/var/data/jenkins_go_cache"
    239. mountPath: "/home/jenkins/go/pkg"
    240. - hostPathVolume:
    241. hostPath: "/var/data/jenkins_sonar_cache"
    242. mountPath: "/root/.sonar/cache"
    243. yaml: "spec:\r\n affinity:\r\n nodeAffinity:\r\n preferredDuringSchedulingIgnoredDuringExecution:\r\n - weight: 1\r\n preference:\r\n matchExpressions:\r\n - key: node-role.kubernetes.io/worker\r\n operator: In\r\n values:\r\n - ci\r\n tolerations:\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"NoSchedule\"\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"PreferNoSchedule\"\r\n containers:\r\n - name: \"go\"\r\n resources:\r\n requests:\r\n ephemeral-storage: \"1Gi\"\r\n limits:\r\n ephemeral-storage: \"10Gi\"\r\n securityContext:\r\n fsGroup: 1000\r\n "
    244. - name: "gradle"
    245. namespace: "kubesphere-devops-system"
    246. label: "gradle"
    247. nodeUsageMode: "EXCLUSIVE"
    248. idleMinutes: 0
    249. containers:
    250. - name: "gradle"
    251. image: "bytest-harbor.ur.com.cn/kubesphere/builder-gradle:v3.1.0"
    252. command: "cat"
    253. args: ""
    254. ttyEnabled: true
    255. resourceRequestCpu: "100m"
    256. resourceLimitCpu: "4000m"
    257. resourceRequestMemory: "100Mi"
    258. resourceLimitMemory: "8192Mi"
    259. - name: "jnlp"
    260. image: "jenkins/jnlp-slave:3.27-1"
    261. command: "jenkins-slave"
    262. args: "^${computer.jnlpmac} ^${computer.name}"
    263. resourceRequestCpu: "50m"
    264. resourceRequestMemory: "400Mi"
    265. resourceLimitMemory: "1536Mi"
    266. workspaceVolume:
    267. emptyDirWorkspaceVolume:
    268. memory: false
    269. volumes:
    270. - hostPathVolume:
    271. hostPath: "/var/run/docker.sock"
    272. mountPath: "/var/run/docker.sock"
    273. - hostPathVolume:
    274. hostPath: "/var/data/jenkins_gradle_cache"
    275. mountPath: "/home/gradle/.gradle"
    276. - hostPathVolume:
    277. hostPath: "/var/data/jenkins_android_sdk"
    278. mountPath: "/usr/local/android-sdk-linux"
    279. - hostPathVolume:
    280. hostPath: "/var/data/jenkins_sonar_cache"
    281. mountPath: "/root/.sonar/cache"
    282. yaml: "spec:\r\n affinity:\r\n nodeAffinity:\r\n preferredDuringSchedulingIgnoredDuringExecution:\r\n - weight: 1\r\n preference:\r\n matchExpressions:\r\n - key: node-role.kubernetes.io/worker\r\n operator: In\r\n values:\r\n - ci\r\n tolerations:\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"NoSchedule\"\r\n - key: \"node.kubernetes.io/ci\"\r\n operator: \"Exists\"\r\n effect: \"PreferNoSchedule\"\r\n containers:\r\n - name: \"gradle\"\r\n resources:\r\n requests:\r\n ephemeral-storage: \"1Gi\"\r\n limits:\r\n ephemeral-storage: \"10Gi\"\r\n securityContext:\r\n fsGroup: 1000\r\n "
    283. securityRealm:
    284. ldap:
    285. configurations:
    286. - displayNameAttributeName: "uid"
    287. mailAddressAttributeName: "mail"
    288. inhibitInferRootDN: false
    289. managerDN: "cn=admin,dc=kubesphere,dc=io"
    290. managerPasswordSecret: "admin"
    291. rootDN: "dc=kubesphere,dc=io"
    292. userSearchBase: "ou=Users"
    293. userSearch: "(&(objectClass=inetOrgPerson)(|(uid={0})(mail={0})))"
    294. groupSearchBase: "ou=Groups"
    295. groupSearchFilter: "(&(objectClass=posixGroup)(cn={0}))"
    296. server: "ldap://openldap.kubesphere-system.svc:389"
    297. disableMailAddressResolver: false
    298. disableRolePrefixing: true
    299. unclassified:
    300. location:
    301. url: "http://jenkins.devops.kubesphere.local:30180/"
    302. kubespheretokenauthglobalconfiguration:
    303. cacheConfiguration:
    304. size: 20
    305. ttl: 300
    306. enabled: true
    307. server: "http://ks-apiserver.kubesphere-system.svc/"
    308. gitLabServers:
    309. servers:
    310. - credentialsId: "pipeline-user-gitlab-token"
    311. name: "ur-dev-gitlab"
    312. secretToken: "{AQAAABAAAAAQdaToIBkc7yxaeORxWOIMsiYhMg3gZlsg4vhCkY5gg/4=}"
    313. serverUrl: "https://git.ur.com.cn"
    314. jobs:
    315. - script: >
    316. pipelineJob('init-job') {
    317. definition {
    318. cps {
    319. script("""\
    320. pipeline {
    321. agent any
    322. stages {
    323. stage ('hello') {
    324. steps {
    325. echo "hello"
    326. }
    327. }
    328. }
    329. }""".stripIndent())
    330. }
    331. }
    332. }

    image.png

    1. echo y|sdkmanager "platform-tools" "platforms;android-32" "build-tools;32.0.0"

    手动更新添加Linux android 编译工具到ci节点机器,然后挂载到流水线容器里
    image.png

    镜像

    1. docker pull liweiming0611/builder-gradle:v3.1.0

    镜像制作
    https://www.yuque.com/liweiming/kubesphere/afcqig