Jenkinsfile 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. #!groovy
  2. pipeline {
  3. agent none
  4. options {
  5. buildDiscarder(logRotator(daysToKeepStr: '30'))
  6. timeout(time: 2, unit: 'HOURS')
  7. timestamps()
  8. }
  9. parameters {
  10. booleanParam(name: 'arm64', defaultValue: true, description: 'ARM (arm64) Build/Test')
  11. booleanParam(name: 's390x', defaultValue: false, description: 'IBM Z (s390x) Build/Test')
  12. booleanParam(name: 'ppc64le', defaultValue: false, description: 'PowerPC (ppc64le) Build/Test')
  13. booleanParam(name: 'dco', defaultValue: true, description: 'Run the DCO check')
  14. }
  15. environment {
  16. DOCKER_BUILDKIT = '1'
  17. DOCKER_EXPERIMENTAL = '1'
  18. DOCKER_GRAPHDRIVER = 'overlay2'
  19. CHECK_CONFIG_COMMIT = '33a3680e08d1007e72c3b3f1454f823d8e9948ee'
  20. TESTDEBUG = '0'
  21. TIMEOUT = '120m'
  22. }
  23. stages {
  24. stage('pr-hack') {
  25. when { changeRequest() }
  26. steps {
  27. script {
  28. echo "Workaround for PR auto-cancel feature. Borrowed from https://issues.jenkins-ci.org/browse/JENKINS-43353"
  29. def buildNumber = env.BUILD_NUMBER as int
  30. if (buildNumber > 1) milestone(buildNumber - 1)
  31. milestone(buildNumber)
  32. }
  33. }
  34. }
  35. stage('DCO-check') {
  36. when {
  37. beforeAgent true
  38. expression { params.dco }
  39. }
  40. agent { label 'arm64 && ubuntu-2004' }
  41. steps {
  42. sh '''
  43. docker run --rm \
  44. -v "$WORKSPACE:/workspace" \
  45. -e VALIDATE_REPO=${GIT_URL} \
  46. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  47. alpine sh -c 'apk add --no-cache -q bash git openssh-client && git config --system --add safe.directory /workspace && cd /workspace && hack/validate/dco'
  48. '''
  49. }
  50. }
  51. stage('Build') {
  52. parallel {
  53. stage('s390x') {
  54. when {
  55. beforeAgent true
  56. // Skip this stage on PRs unless the checkbox is selected
  57. anyOf {
  58. not { changeRequest() }
  59. expression { params.s390x }
  60. }
  61. }
  62. agent { label 's390x-ubuntu-2004' }
  63. stages {
  64. stage("Print info") {
  65. steps {
  66. sh 'docker version'
  67. sh 'docker info'
  68. sh '''
  69. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  70. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  71. && bash ${WORKSPACE}/check-config.sh || true
  72. '''
  73. }
  74. }
  75. stage("Build dev image") {
  76. steps {
  77. sh '''
  78. docker build --force-rm -t docker:${GIT_COMMIT} .
  79. '''
  80. }
  81. }
  82. stage("Unit tests") {
  83. steps {
  84. sh '''
  85. sudo modprobe ip6table_filter
  86. '''
  87. sh '''
  88. docker run --rm -t --privileged \
  89. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  90. --name docker-pr$BUILD_NUMBER \
  91. -e DOCKER_EXPERIMENTAL \
  92. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  93. -e DOCKER_GRAPHDRIVER \
  94. -e VALIDATE_REPO=${GIT_URL} \
  95. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  96. docker:${GIT_COMMIT} \
  97. hack/test/unit
  98. '''
  99. }
  100. post {
  101. always {
  102. junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true
  103. }
  104. }
  105. }
  106. stage("Integration tests") {
  107. environment { TEST_SKIP_INTEGRATION_CLI = '1' }
  108. steps {
  109. sh '''
  110. docker run --rm -t --privileged \
  111. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  112. --name docker-pr$BUILD_NUMBER \
  113. -e DOCKER_EXPERIMENTAL \
  114. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  115. -e DOCKER_GRAPHDRIVER \
  116. -e TESTDEBUG \
  117. -e TEST_INTEGRATION_USE_SNAPSHOTTER \
  118. -e TEST_SKIP_INTEGRATION_CLI \
  119. -e TIMEOUT \
  120. -e VALIDATE_REPO=${GIT_URL} \
  121. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  122. docker:${GIT_COMMIT} \
  123. hack/make.sh \
  124. dynbinary \
  125. test-integration
  126. '''
  127. }
  128. post {
  129. always {
  130. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  131. }
  132. }
  133. }
  134. }
  135. post {
  136. always {
  137. sh '''
  138. echo "Ensuring container killed."
  139. docker rm -vf docker-pr$BUILD_NUMBER || true
  140. '''
  141. sh '''
  142. echo "Chowning /workspace to jenkins user"
  143. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  144. '''
  145. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  146. sh '''
  147. bundleName=s390x-integration
  148. echo "Creating ${bundleName}-bundles.tar.gz"
  149. # exclude overlay2 directories
  150. find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*-report.json' -o -name '*.log' -o -name '*.prof' -o -name '*-report.xml' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
  151. '''
  152. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  153. }
  154. }
  155. cleanup {
  156. sh 'make clean'
  157. deleteDir()
  158. }
  159. }
  160. }
  161. stage('s390x integration-cli') {
  162. when {
  163. beforeAgent true
  164. // Skip this stage on PRs unless the checkbox is selected
  165. anyOf {
  166. not { changeRequest() }
  167. expression { params.s390x }
  168. }
  169. }
  170. agent { label 's390x-ubuntu-2004' }
  171. stages {
  172. stage("Print info") {
  173. steps {
  174. sh 'docker version'
  175. sh 'docker info'
  176. sh '''
  177. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  178. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  179. && bash ${WORKSPACE}/check-config.sh || true
  180. '''
  181. }
  182. }
  183. stage("Build dev image") {
  184. steps {
  185. sh '''
  186. docker build --force-rm -t docker:${GIT_COMMIT} .
  187. '''
  188. }
  189. }
  190. stage("Integration-cli tests") {
  191. environment { TEST_SKIP_INTEGRATION = '1' }
  192. steps {
  193. sh '''
  194. docker run --rm -t --privileged \
  195. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  196. --name docker-pr$BUILD_NUMBER \
  197. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  198. -e DOCKER_GRAPHDRIVER \
  199. -e TEST_INTEGRATION_USE_SNAPSHOTTER \
  200. -e TEST_SKIP_INTEGRATION \
  201. -e TIMEOUT \
  202. -e VALIDATE_REPO=${GIT_URL} \
  203. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  204. docker:${GIT_COMMIT} \
  205. hack/make.sh \
  206. dynbinary \
  207. test-integration
  208. '''
  209. }
  210. post {
  211. always {
  212. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  213. }
  214. }
  215. }
  216. }
  217. post {
  218. always {
  219. sh '''
  220. echo "Ensuring container killed."
  221. docker rm -vf docker-pr$BUILD_NUMBER || true
  222. '''
  223. sh '''
  224. echo "Chowning /workspace to jenkins user"
  225. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  226. '''
  227. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  228. sh '''
  229. bundleName=s390x-integration-cli
  230. echo "Creating ${bundleName}-bundles.tar.gz"
  231. # exclude overlay2 directories
  232. find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*-report.json' -o -name '*.log' -o -name '*.prof' -o -name '*-report.xml' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
  233. '''
  234. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  235. }
  236. }
  237. cleanup {
  238. sh 'make clean'
  239. deleteDir()
  240. }
  241. }
  242. }
  243. stage('ppc64le') {
  244. when {
  245. beforeAgent true
  246. // Skip this stage on PRs unless the checkbox is selected
  247. anyOf {
  248. not { changeRequest() }
  249. expression { params.ppc64le }
  250. }
  251. }
  252. agent { label 'ppc64le-ubuntu-1604' }
  253. stages {
  254. stage("Print info") {
  255. steps {
  256. sh 'docker version'
  257. sh 'docker info'
  258. sh '''
  259. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  260. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  261. && bash ${WORKSPACE}/check-config.sh || true
  262. '''
  263. }
  264. }
  265. stage("Build dev image") {
  266. steps {
  267. sh '''
  268. docker buildx build --load --force-rm -t docker:${GIT_COMMIT} .
  269. '''
  270. }
  271. }
  272. stage("Unit tests") {
  273. steps {
  274. sh '''
  275. sudo modprobe ip6table_filter
  276. '''
  277. sh '''
  278. docker run --rm -t --privileged \
  279. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  280. --name docker-pr$BUILD_NUMBER \
  281. -e DOCKER_EXPERIMENTAL \
  282. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  283. -e DOCKER_GRAPHDRIVER \
  284. -e VALIDATE_REPO=${GIT_URL} \
  285. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  286. docker:${GIT_COMMIT} \
  287. hack/test/unit
  288. '''
  289. }
  290. post {
  291. always {
  292. junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true
  293. }
  294. }
  295. }
  296. stage("Integration tests") {
  297. environment { TEST_SKIP_INTEGRATION_CLI = '1' }
  298. steps {
  299. sh '''
  300. docker run --rm -t --privileged \
  301. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  302. --name docker-pr$BUILD_NUMBER \
  303. -e DOCKER_EXPERIMENTAL \
  304. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  305. -e DOCKER_GRAPHDRIVER \
  306. -e TESTDEBUG \
  307. -e TEST_INTEGRATION_USE_SNAPSHOTTER \
  308. -e TEST_SKIP_INTEGRATION_CLI \
  309. -e TIMEOUT \
  310. -e VALIDATE_REPO=${GIT_URL} \
  311. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  312. docker:${GIT_COMMIT} \
  313. hack/make.sh \
  314. dynbinary \
  315. test-integration
  316. '''
  317. }
  318. post {
  319. always {
  320. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  321. }
  322. }
  323. }
  324. }
  325. post {
  326. always {
  327. sh '''
  328. echo "Ensuring container killed."
  329. docker rm -vf docker-pr$BUILD_NUMBER || true
  330. '''
  331. sh '''
  332. echo "Chowning /workspace to jenkins user"
  333. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  334. '''
  335. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  336. sh '''
  337. bundleName=ppc64le-integration
  338. echo "Creating ${bundleName}-bundles.tar.gz"
  339. # exclude overlay2 directories
  340. find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*-report.json' -o -name '*.log' -o -name '*.prof' -o -name '*-report.xml' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
  341. '''
  342. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  343. }
  344. }
  345. cleanup {
  346. sh 'make clean'
  347. deleteDir()
  348. }
  349. }
  350. }
  351. stage('ppc64le integration-cli') {
  352. when {
  353. beforeAgent true
  354. // Skip this stage on PRs unless the checkbox is selected
  355. anyOf {
  356. not { changeRequest() }
  357. expression { params.ppc64le }
  358. }
  359. }
  360. agent { label 'ppc64le-ubuntu-1604' }
  361. stages {
  362. stage("Print info") {
  363. steps {
  364. sh 'docker version'
  365. sh 'docker info'
  366. sh '''
  367. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  368. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  369. && bash ${WORKSPACE}/check-config.sh || true
  370. '''
  371. }
  372. }
  373. stage("Build dev image") {
  374. steps {
  375. sh '''
  376. docker buildx build --load --force-rm -t docker:${GIT_COMMIT} .
  377. '''
  378. }
  379. }
  380. stage("Integration-cli tests") {
  381. environment { TEST_SKIP_INTEGRATION = '1' }
  382. steps {
  383. sh '''
  384. docker run --rm -t --privileged \
  385. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  386. --name docker-pr$BUILD_NUMBER \
  387. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  388. -e DOCKER_GRAPHDRIVER \
  389. -e TEST_INTEGRATION_USE_SNAPSHOTTER \
  390. -e TEST_SKIP_INTEGRATION \
  391. -e TIMEOUT \
  392. -e VALIDATE_REPO=${GIT_URL} \
  393. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  394. docker:${GIT_COMMIT} \
  395. hack/make.sh \
  396. dynbinary \
  397. test-integration
  398. '''
  399. }
  400. post {
  401. always {
  402. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  403. }
  404. }
  405. }
  406. }
  407. post {
  408. always {
  409. sh '''
  410. echo "Ensuring container killed."
  411. docker rm -vf docker-pr$BUILD_NUMBER || true
  412. '''
  413. sh '''
  414. echo "Chowning /workspace to jenkins user"
  415. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  416. '''
  417. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  418. sh '''
  419. bundleName=ppc64le-integration-cli
  420. echo "Creating ${bundleName}-bundles.tar.gz"
  421. # exclude overlay2 directories
  422. find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*-report.json' -o -name '*.log' -o -name '*.prof' -o -name '*-report.xml' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
  423. '''
  424. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  425. }
  426. }
  427. cleanup {
  428. sh 'make clean'
  429. deleteDir()
  430. }
  431. }
  432. }
  433. stage('arm64') {
  434. when {
  435. beforeAgent true
  436. expression { params.arm64 }
  437. }
  438. agent { label 'arm64 && ubuntu-2004' }
  439. environment {
  440. TEST_SKIP_INTEGRATION_CLI = '1'
  441. }
  442. stages {
  443. stage("Print info") {
  444. steps {
  445. sh 'docker version'
  446. sh 'docker info'
  447. sh '''
  448. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  449. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  450. && bash ${WORKSPACE}/check-config.sh || true
  451. '''
  452. }
  453. }
  454. stage("Build dev image") {
  455. steps {
  456. sh 'docker build --force-rm -t docker:${GIT_COMMIT} .'
  457. }
  458. }
  459. stage("Unit tests") {
  460. steps {
  461. sh '''
  462. sudo modprobe ip6table_filter
  463. '''
  464. sh '''
  465. docker run --rm -t --privileged \
  466. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  467. --name docker-pr$BUILD_NUMBER \
  468. -e DOCKER_EXPERIMENTAL \
  469. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  470. -e DOCKER_GRAPHDRIVER \
  471. -e VALIDATE_REPO=${GIT_URL} \
  472. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  473. docker:${GIT_COMMIT} \
  474. hack/test/unit
  475. '''
  476. }
  477. post {
  478. always {
  479. junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true
  480. }
  481. }
  482. }
  483. stage("Integration tests") {
  484. environment { TEST_SKIP_INTEGRATION_CLI = '1' }
  485. steps {
  486. sh '''
  487. docker run --rm -t --privileged \
  488. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  489. --name docker-pr$BUILD_NUMBER \
  490. -e DOCKER_EXPERIMENTAL \
  491. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  492. -e DOCKER_GRAPHDRIVER \
  493. -e TESTDEBUG \
  494. -e TEST_INTEGRATION_USE_SNAPSHOTTER \
  495. -e TEST_SKIP_INTEGRATION_CLI \
  496. -e TIMEOUT \
  497. -e VALIDATE_REPO=${GIT_URL} \
  498. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  499. docker:${GIT_COMMIT} \
  500. hack/make.sh \
  501. dynbinary \
  502. test-integration
  503. '''
  504. }
  505. post {
  506. always {
  507. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  508. }
  509. }
  510. }
  511. }
  512. post {
  513. always {
  514. sh '''
  515. echo "Ensuring container killed."
  516. docker rm -vf docker-pr$BUILD_NUMBER || true
  517. '''
  518. sh '''
  519. echo "Chowning /workspace to jenkins user"
  520. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  521. '''
  522. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  523. sh '''
  524. bundleName=arm64-integration
  525. echo "Creating ${bundleName}-bundles.tar.gz"
  526. # exclude overlay2 directories
  527. find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*-report.json' -o -name '*.log' -o -name '*.prof' -o -name '*-report.xml' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
  528. '''
  529. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  530. }
  531. }
  532. cleanup {
  533. sh 'make clean'
  534. deleteDir()
  535. }
  536. }
  537. }
  538. }
  539. }
  540. }
  541. }