Jenkinsfile 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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. APT_MIRROR = 'cdn-fastly.deb.debian.org'
  20. CHECK_CONFIG_COMMIT = '33a3680e08d1007e72c3b3f1454f823d8e9948ee'
  21. TESTDEBUG = '0'
  22. TIMEOUT = '120m'
  23. }
  24. stages {
  25. stage('pr-hack') {
  26. when { changeRequest() }
  27. steps {
  28. script {
  29. echo "Workaround for PR auto-cancel feature. Borrowed from https://issues.jenkins-ci.org/browse/JENKINS-43353"
  30. def buildNumber = env.BUILD_NUMBER as int
  31. if (buildNumber > 1) milestone(buildNumber - 1)
  32. milestone(buildNumber)
  33. }
  34. }
  35. }
  36. stage('DCO-check') {
  37. when {
  38. beforeAgent true
  39. expression { params.dco }
  40. }
  41. agent { label 'arm64 && ubuntu-2004' }
  42. steps {
  43. sh '''
  44. docker run --rm \
  45. -v "$WORKSPACE:/workspace" \
  46. -e VALIDATE_REPO=${GIT_URL} \
  47. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  48. alpine sh -c 'apk add --no-cache -q bash git openssh-client && git config --system --add safe.directory /workspace && cd /workspace && hack/validate/dco'
  49. '''
  50. }
  51. }
  52. stage('Build') {
  53. parallel {
  54. stage('s390x') {
  55. when {
  56. beforeAgent true
  57. // Skip this stage on PRs unless the checkbox is selected
  58. anyOf {
  59. not { changeRequest() }
  60. expression { params.s390x }
  61. }
  62. }
  63. agent { label 's390x-ubuntu-2004' }
  64. stages {
  65. stage("Print info") {
  66. steps {
  67. sh 'docker version'
  68. sh 'docker info'
  69. sh '''
  70. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  71. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  72. && bash ${WORKSPACE}/check-config.sh || true
  73. '''
  74. }
  75. }
  76. stage("Build dev image") {
  77. steps {
  78. sh '''
  79. docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
  80. '''
  81. }
  82. }
  83. stage("Unit tests") {
  84. steps {
  85. sh '''
  86. sudo modprobe ip6table_filter
  87. '''
  88. sh '''
  89. docker run --rm -t --privileged \
  90. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  91. --name docker-pr$BUILD_NUMBER \
  92. -e DOCKER_EXPERIMENTAL \
  93. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  94. -e DOCKER_GRAPHDRIVER \
  95. -e VALIDATE_REPO=${GIT_URL} \
  96. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  97. docker:${GIT_COMMIT} \
  98. hack/test/unit
  99. '''
  100. }
  101. post {
  102. always {
  103. junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true
  104. }
  105. }
  106. }
  107. stage("Integration tests") {
  108. environment { TEST_SKIP_INTEGRATION_CLI = '1' }
  109. steps {
  110. sh '''
  111. docker run --rm -t --privileged \
  112. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  113. --name docker-pr$BUILD_NUMBER \
  114. -e DOCKER_EXPERIMENTAL \
  115. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  116. -e DOCKER_GRAPHDRIVER \
  117. -e TESTDEBUG \
  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 --build-arg APT_MIRROR -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_SKIP_INTEGRATION \
  200. -e TIMEOUT \
  201. -e VALIDATE_REPO=${GIT_URL} \
  202. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  203. docker:${GIT_COMMIT} \
  204. hack/make.sh \
  205. dynbinary \
  206. test-integration
  207. '''
  208. }
  209. post {
  210. always {
  211. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  212. }
  213. }
  214. }
  215. }
  216. post {
  217. always {
  218. sh '''
  219. echo "Ensuring container killed."
  220. docker rm -vf docker-pr$BUILD_NUMBER || true
  221. '''
  222. sh '''
  223. echo "Chowning /workspace to jenkins user"
  224. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  225. '''
  226. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  227. sh '''
  228. bundleName=s390x-integration-cli
  229. echo "Creating ${bundleName}-bundles.tar.gz"
  230. # exclude overlay2 directories
  231. 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
  232. '''
  233. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  234. }
  235. }
  236. cleanup {
  237. sh 'make clean'
  238. deleteDir()
  239. }
  240. }
  241. }
  242. stage('ppc64le') {
  243. when {
  244. beforeAgent true
  245. // Skip this stage on PRs unless the checkbox is selected
  246. anyOf {
  247. not { changeRequest() }
  248. expression { params.ppc64le }
  249. }
  250. }
  251. agent { label 'ppc64le-ubuntu-1604' }
  252. // ppc64le machines run on Docker 18.06, and buildkit has some
  253. // bugs on that version. Build and use buildx instead.
  254. environment {
  255. USE_BUILDX = '1'
  256. DOCKER_BUILDKIT = '0'
  257. }
  258. stages {
  259. stage("Print info") {
  260. steps {
  261. sh 'docker version'
  262. sh 'docker info'
  263. sh '''
  264. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  265. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  266. && bash ${WORKSPACE}/check-config.sh || true
  267. '''
  268. }
  269. }
  270. stage("Build dev image") {
  271. steps {
  272. sh '''
  273. make bundles/buildx
  274. bundles/buildx build --load --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
  275. '''
  276. }
  277. }
  278. stage("Unit tests") {
  279. steps {
  280. sh '''
  281. sudo modprobe ip6table_filter
  282. '''
  283. sh '''
  284. docker run --rm -t --privileged \
  285. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  286. --name docker-pr$BUILD_NUMBER \
  287. -e DOCKER_EXPERIMENTAL \
  288. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  289. -e DOCKER_GRAPHDRIVER \
  290. -e VALIDATE_REPO=${GIT_URL} \
  291. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  292. docker:${GIT_COMMIT} \
  293. hack/test/unit
  294. '''
  295. }
  296. post {
  297. always {
  298. junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true
  299. }
  300. }
  301. }
  302. stage("Integration tests") {
  303. environment { TEST_SKIP_INTEGRATION_CLI = '1' }
  304. steps {
  305. sh '''
  306. docker run --rm -t --privileged \
  307. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  308. --name docker-pr$BUILD_NUMBER \
  309. -e DOCKER_EXPERIMENTAL \
  310. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  311. -e DOCKER_GRAPHDRIVER \
  312. -e TESTDEBUG \
  313. -e TEST_SKIP_INTEGRATION_CLI \
  314. -e TIMEOUT \
  315. -e VALIDATE_REPO=${GIT_URL} \
  316. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  317. docker:${GIT_COMMIT} \
  318. hack/make.sh \
  319. dynbinary \
  320. test-integration
  321. '''
  322. }
  323. post {
  324. always {
  325. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  326. }
  327. }
  328. }
  329. }
  330. post {
  331. always {
  332. sh '''
  333. echo "Ensuring container killed."
  334. docker rm -vf docker-pr$BUILD_NUMBER || true
  335. '''
  336. sh '''
  337. echo "Chowning /workspace to jenkins user"
  338. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  339. '''
  340. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  341. sh '''
  342. bundleName=ppc64le-integration
  343. echo "Creating ${bundleName}-bundles.tar.gz"
  344. # exclude overlay2 directories
  345. 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
  346. '''
  347. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  348. }
  349. }
  350. cleanup {
  351. sh 'make clean'
  352. deleteDir()
  353. }
  354. }
  355. }
  356. stage('ppc64le integration-cli') {
  357. when {
  358. beforeAgent true
  359. // Skip this stage on PRs unless the checkbox is selected
  360. anyOf {
  361. not { changeRequest() }
  362. expression { params.ppc64le }
  363. }
  364. }
  365. agent { label 'ppc64le-ubuntu-1604' }
  366. // ppc64le machines run on Docker 18.06, and buildkit has some
  367. // bugs on that version. Build and use buildx instead.
  368. environment {
  369. USE_BUILDX = '1'
  370. DOCKER_BUILDKIT = '0'
  371. }
  372. stages {
  373. stage("Print info") {
  374. steps {
  375. sh 'docker version'
  376. sh 'docker info'
  377. sh '''
  378. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  379. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  380. && bash ${WORKSPACE}/check-config.sh || true
  381. '''
  382. }
  383. }
  384. stage("Build dev image") {
  385. steps {
  386. sh '''
  387. make bundles/buildx
  388. bundles/buildx build --load --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
  389. '''
  390. }
  391. }
  392. stage("Integration-cli tests") {
  393. environment { TEST_SKIP_INTEGRATION = '1' }
  394. steps {
  395. sh '''
  396. docker run --rm -t --privileged \
  397. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  398. --name docker-pr$BUILD_NUMBER \
  399. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  400. -e DOCKER_GRAPHDRIVER \
  401. -e TEST_SKIP_INTEGRATION \
  402. -e TIMEOUT \
  403. -e VALIDATE_REPO=${GIT_URL} \
  404. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  405. docker:${GIT_COMMIT} \
  406. hack/make.sh \
  407. dynbinary \
  408. test-integration
  409. '''
  410. }
  411. post {
  412. always {
  413. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  414. }
  415. }
  416. }
  417. }
  418. post {
  419. always {
  420. sh '''
  421. echo "Ensuring container killed."
  422. docker rm -vf docker-pr$BUILD_NUMBER || true
  423. '''
  424. sh '''
  425. echo "Chowning /workspace to jenkins user"
  426. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  427. '''
  428. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  429. sh '''
  430. bundleName=ppc64le-integration-cli
  431. echo "Creating ${bundleName}-bundles.tar.gz"
  432. # exclude overlay2 directories
  433. 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
  434. '''
  435. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  436. }
  437. }
  438. cleanup {
  439. sh 'make clean'
  440. deleteDir()
  441. }
  442. }
  443. }
  444. stage('arm64') {
  445. when {
  446. beforeAgent true
  447. expression { params.arm64 }
  448. }
  449. agent { label 'arm64 && ubuntu-2004' }
  450. environment {
  451. TEST_SKIP_INTEGRATION_CLI = '1'
  452. }
  453. stages {
  454. stage("Print info") {
  455. steps {
  456. sh 'docker version'
  457. sh 'docker info'
  458. sh '''
  459. echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
  460. curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
  461. && bash ${WORKSPACE}/check-config.sh || true
  462. '''
  463. }
  464. }
  465. stage("Build dev image") {
  466. steps {
  467. sh 'docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .'
  468. }
  469. }
  470. stage("Unit tests") {
  471. steps {
  472. sh '''
  473. sudo modprobe ip6table_filter
  474. '''
  475. sh '''
  476. docker run --rm -t --privileged \
  477. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  478. --name docker-pr$BUILD_NUMBER \
  479. -e DOCKER_EXPERIMENTAL \
  480. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  481. -e DOCKER_GRAPHDRIVER \
  482. -e VALIDATE_REPO=${GIT_URL} \
  483. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  484. docker:${GIT_COMMIT} \
  485. hack/test/unit
  486. '''
  487. }
  488. post {
  489. always {
  490. junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true
  491. }
  492. }
  493. }
  494. stage("Integration tests") {
  495. environment { TEST_SKIP_INTEGRATION_CLI = '1' }
  496. steps {
  497. sh '''
  498. docker run --rm -t --privileged \
  499. -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
  500. --name docker-pr$BUILD_NUMBER \
  501. -e DOCKER_EXPERIMENTAL \
  502. -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
  503. -e DOCKER_GRAPHDRIVER \
  504. -e TESTDEBUG \
  505. -e TEST_SKIP_INTEGRATION_CLI \
  506. -e TIMEOUT \
  507. -e VALIDATE_REPO=${GIT_URL} \
  508. -e VALIDATE_BRANCH=${CHANGE_TARGET} \
  509. docker:${GIT_COMMIT} \
  510. hack/make.sh \
  511. dynbinary \
  512. test-integration
  513. '''
  514. }
  515. post {
  516. always {
  517. junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
  518. }
  519. }
  520. }
  521. }
  522. post {
  523. always {
  524. sh '''
  525. echo "Ensuring container killed."
  526. docker rm -vf docker-pr$BUILD_NUMBER || true
  527. '''
  528. sh '''
  529. echo "Chowning /workspace to jenkins user"
  530. docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
  531. '''
  532. catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  533. sh '''
  534. bundleName=arm64-integration
  535. echo "Creating ${bundleName}-bundles.tar.gz"
  536. # exclude overlay2 directories
  537. 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
  538. '''
  539. archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
  540. }
  541. }
  542. cleanup {
  543. sh 'make clean'
  544. deleteDir()
  545. }
  546. }
  547. }
  548. }
  549. }
  550. }
  551. }