github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/Jenkinsfile (about)

     1  #!groovy
     2  pipeline {
     3      agent none
     4  
     5      options {
     6          buildDiscarder(logRotator(daysToKeepStr: '30'))
     7          timeout(time: 2, unit: 'HOURS')
     8          timestamps()
     9      }
    10      parameters {
    11          booleanParam(name: 'unit_validate', defaultValue: true, description: 'amd64 (x86_64) unit tests and vendor check')
    12          booleanParam(name: 'validate_force', defaultValue: false, description: 'force validation steps to be run, even if no changes were detected')
    13          booleanParam(name: 'amd64', defaultValue: true, description: 'amd64 (x86_64) Build/Test')
    14          booleanParam(name: 'rootless', defaultValue: true, description: 'amd64 (x86_64) Build/Test (Rootless mode)')
    15          booleanParam(name: 'arm64', defaultValue: true, description: 'ARM (arm64) Build/Test')
    16          booleanParam(name: 's390x', defaultValue: true, description: 'IBM Z (s390x) Build/Test')
    17          booleanParam(name: 'ppc64le', defaultValue: true, description: 'PowerPC (ppc64le) Build/Test')
    18          booleanParam(name: 'windowsRS1', defaultValue: false, description: 'Windows 2016 (RS1) Build/Test')
    19          booleanParam(name: 'windowsRS5', defaultValue: true, description: 'Windows 2019 (RS5) Build/Test')
    20          booleanParam(name: 'dco', defaultValue: true, description: 'Run the DCO check')
    21      }
    22      environment {
    23          DOCKER_BUILDKIT     = '1'
    24          DOCKER_EXPERIMENTAL = '1'
    25          DOCKER_GRAPHDRIVER  = 'overlay2'
    26          APT_MIRROR          = 'cdn-fastly.deb.debian.org'
    27          CHECK_CONFIG_COMMIT = '78405559cfe5987174aa2cb6463b9b2c1b917255'
    28          TESTDEBUG           = '0'
    29          TIMEOUT             = '120m'
    30      }
    31      stages {
    32          stage('pr-hack') {
    33              when { changeRequest() }
    34              steps {
    35                  script {
    36                      echo "Workaround for PR auto-cancel feature. Borrowed from https://issues.jenkins-ci.org/browse/JENKINS-43353"
    37                      def buildNumber = env.BUILD_NUMBER as int
    38                      if (buildNumber > 1) milestone(buildNumber - 1)
    39                      milestone(buildNumber)
    40                  }
    41              }
    42          }
    43          stage('DCO-check') {
    44              when {
    45                  beforeAgent true
    46                  expression { params.dco }
    47              }
    48              agent { label 'amd64 && ubuntu-1804 && overlay2' }
    49              steps {
    50                  sh '''
    51                  docker run --rm \
    52                    -v "$WORKSPACE:/workspace" \
    53                    -e VALIDATE_REPO=${GIT_URL} \
    54                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
    55                    alpine sh -c 'apk add --no-cache -q bash git openssh-client && cd /workspace && hack/validate/dco'
    56                  '''
    57              }
    58          }
    59          stage('Build') {
    60              parallel {
    61                  stage('unit-validate') {
    62                      when {
    63                          beforeAgent true
    64                          expression { params.unit_validate }
    65                      }
    66                      agent { label 'amd64 && ubuntu-1804 && overlay2' }
    67                      environment {
    68                          // On master ("non-pull-request"), force running some validation checks (vendor, swagger),
    69                          // even if no files were changed. This allows catching problems caused by pull-requests
    70                          // that were merged out-of-sequence.
    71                          TEST_FORCE_VALIDATE = sh returnStdout: true, script: 'if [ "${BRANCH_NAME%%-*}" != "PR" ] || [ "${CHANGE_TARGET:-master}" != "master" ] || [ "${validate_force}" = "true" ]; then echo "1"; fi'
    72                      }
    73  
    74                      stages {
    75                          stage("Print info") {
    76                              steps {
    77                                  sh 'docker version'
    78                                  sh 'docker info'
    79                                  sh '''
    80                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
    81                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
    82                                  && bash ${WORKSPACE}/check-config.sh || true
    83                                  '''
    84                              }
    85                          }
    86                          stage("Build dev image") {
    87                              steps {
    88                                  sh 'docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .'
    89                              }
    90                          }
    91                          stage("Validate") {
    92                              steps {
    93                                  sh '''
    94                                  docker run --rm -t --privileged \
    95                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
    96                                    -v "$WORKSPACE/.git:/go/src/github.com/docker/docker/.git" \
    97                                    --name docker-pr$BUILD_NUMBER \
    98                                    -e DOCKER_EXPERIMENTAL \
    99                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   100                                    -e DOCKER_GRAPHDRIVER \
   101                                    -e TEST_FORCE_VALIDATE \
   102                                    -e VALIDATE_REPO=${GIT_URL} \
   103                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   104                                    docker:${GIT_COMMIT} \
   105                                    hack/validate/default
   106                                  '''
   107                              }
   108                          }
   109                          stage("Docker-py") {
   110                              steps {
   111                                  sh '''
   112                                  docker run --rm -t --privileged \
   113                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   114                                    --name docker-pr$BUILD_NUMBER \
   115                                    -e DOCKER_EXPERIMENTAL \
   116                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   117                                    -e DOCKER_GRAPHDRIVER \
   118                                    -e VALIDATE_REPO=${GIT_URL} \
   119                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   120                                    docker:${GIT_COMMIT} \
   121                                    hack/make.sh \
   122                                      dynbinary-daemon \
   123                                      test-docker-py
   124                                  '''
   125                              }
   126                              post {
   127                                  always {
   128                                      junit testResults: 'bundles/test-docker-py/junit-report.xml', allowEmptyResults: true
   129  
   130                                      sh '''
   131                                      echo "Ensuring container killed."
   132                                      docker rm -vf docker-pr$BUILD_NUMBER || true
   133                                      '''
   134  
   135                                      sh '''
   136                                      echo 'Chowning /workspace to jenkins user'
   137                                      docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   138                                      '''
   139  
   140                                      catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   141                                          sh '''
   142                                          bundleName=docker-py
   143                                          echo "Creating ${bundleName}-bundles.tar.gz"
   144                                          tar -czf ${bundleName}-bundles.tar.gz bundles/test-docker-py/*.xml bundles/test-docker-py/*.log
   145                                          '''
   146  
   147                                          archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   148                                      }
   149                                  }
   150                              }
   151                          }
   152                          stage("Static") {
   153                              steps {
   154                                  sh '''
   155                                  docker run --rm -t --privileged \
   156                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   157                                    --name docker-pr$BUILD_NUMBER \
   158                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   159                                    -e DOCKER_GRAPHDRIVER \
   160                                    docker:${GIT_COMMIT} \
   161                                    hack/make.sh binary-daemon
   162                                  '''
   163                              }
   164                          }
   165                          stage("Cross") {
   166                              steps {
   167                                  sh '''
   168                                  docker run --rm -t --privileged \
   169                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   170                                    --name docker-pr$BUILD_NUMBER \
   171                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   172                                    -e DOCKER_GRAPHDRIVER \
   173                                    docker:${GIT_COMMIT} \
   174                                    hack/make.sh cross
   175                                  '''
   176                              }
   177                          }
   178                          // needs to be last stage that calls make.sh for the junit report to work
   179                          stage("Unit tests") {
   180                              steps {
   181                                  sh '''
   182                                  docker run --rm -t --privileged \
   183                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   184                                    --name docker-pr$BUILD_NUMBER \
   185                                    -e DOCKER_EXPERIMENTAL \
   186                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   187                                    -e DOCKER_GRAPHDRIVER \
   188                                    -e VALIDATE_REPO=${GIT_URL} \
   189                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   190                                    docker:${GIT_COMMIT} \
   191                                    hack/test/unit
   192                                  '''
   193                              }
   194                              post {
   195                                  always {
   196                                      junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true
   197                                  }
   198                              }
   199                          }
   200                          stage("Validate vendor") {
   201                              steps {
   202                                  sh '''
   203                                  docker run --rm -t --privileged \
   204                                    -v "$WORKSPACE/.git:/go/src/github.com/docker/docker/.git" \
   205                                    --name docker-pr$BUILD_NUMBER \
   206                                    -e DOCKER_EXPERIMENTAL \
   207                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   208                                    -e DOCKER_GRAPHDRIVER \
   209                                    -e TEST_FORCE_VALIDATE \
   210                                    -e VALIDATE_REPO=${GIT_URL} \
   211                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   212                                    docker:${GIT_COMMIT} \
   213                                    hack/validate/vendor
   214                                  '''
   215                              }
   216                          }
   217                          stage("Build e2e image") {
   218                              steps {
   219                                  sh '''
   220                                  echo "Building e2e image"
   221                                  docker build --build-arg DOCKER_GITCOMMIT=${GIT_COMMIT} -t moby-e2e-test -f Dockerfile.e2e .
   222                                  '''
   223                              }
   224                          }
   225                      }
   226  
   227                      post {
   228                          always {
   229                              sh '''
   230                              echo 'Ensuring container killed.'
   231                              docker rm -vf docker-pr$BUILD_NUMBER || true
   232                              '''
   233  
   234                              sh '''
   235                              echo 'Chowning /workspace to jenkins user'
   236                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   237                              '''
   238  
   239                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   240                                  sh '''
   241                                  bundleName=unit
   242                                  echo "Creating ${bundleName}-bundles.tar.gz"
   243                                  tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report.xml bundles/go-test-report.json bundles/profile.out
   244                                  '''
   245  
   246                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   247                              }
   248                          }
   249                          cleanup {
   250                              sh 'make clean'
   251                              deleteDir()
   252                          }
   253                      }
   254                  }
   255                  stage('amd64') {
   256                      when {
   257                          beforeAgent true
   258                          expression { params.amd64 }
   259                      }
   260                      agent { label 'amd64 && ubuntu-1804 && overlay2' }
   261  
   262                      stages {
   263                          stage("Print info") {
   264                              steps {
   265                                  sh 'docker version'
   266                                  sh 'docker info'
   267                                  sh '''
   268                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
   269                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
   270                                  && bash ${WORKSPACE}/check-config.sh || true
   271                                  '''
   272                              }
   273                          }
   274                          stage("Build dev image") {
   275                              steps {
   276                                  sh '''
   277                                  # todo: include ip_vs in base image
   278                                  sudo modprobe ip_vs
   279  
   280                                  docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
   281                                  '''
   282                              }
   283                          }
   284                          stage("Run tests") {
   285                              steps {
   286                                  sh '''#!/bin/bash
   287                                  # bash is needed so 'jobs -p' works properly
   288                                  # it also accepts setting inline envvars for functions without explicitly exporting
   289                                  set -x
   290  
   291                                  run_tests() {
   292                                          [ -n "$TESTDEBUG" ] && rm= || rm=--rm;
   293                                          docker run $rm -t --privileged \
   294                                            -v "$WORKSPACE/bundles/${TEST_INTEGRATION_DEST}:/go/src/github.com/docker/docker/bundles" \
   295                                            -v "$WORKSPACE/bundles/dynbinary-daemon:/go/src/github.com/docker/docker/bundles/dynbinary-daemon" \
   296                                            -v "$WORKSPACE/.git:/go/src/github.com/docker/docker/.git" \
   297                                            --name "$CONTAINER_NAME" \
   298                                            -e KEEPBUNDLE=1 \
   299                                            -e TESTDEBUG \
   300                                            -e TESTFLAGS \
   301                                            -e TEST_SKIP_INTEGRATION \
   302                                            -e TEST_SKIP_INTEGRATION_CLI \
   303                                            -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   304                                            -e DOCKER_GRAPHDRIVER \
   305                                            -e TIMEOUT \
   306                                            -e VALIDATE_REPO=${GIT_URL} \
   307                                            -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   308                                            docker:${GIT_COMMIT} \
   309                                            hack/make.sh \
   310                                              "$1" \
   311                                              test-integration
   312                                  }
   313  
   314                                  trap "exit" INT TERM
   315                                  trap 'pids=$(jobs -p); echo "Remaining pids to kill: [$pids]"; [ -z "$pids" ] || kill $pids' EXIT
   316  
   317                                  CONTAINER_NAME=docker-pr$BUILD_NUMBER
   318  
   319                                  docker run --rm -t --privileged \
   320                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   321                                    -v "$WORKSPACE/.git:/go/src/github.com/docker/docker/.git" \
   322                                    --name ${CONTAINER_NAME}-build \
   323                                    -e DOCKER_EXPERIMENTAL \
   324                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   325                                    -e DOCKER_GRAPHDRIVER \
   326                                    docker:${GIT_COMMIT} \
   327                                    hack/make.sh \
   328                                      dynbinary-daemon
   329  
   330                                  # flaky + integration
   331                                  TEST_INTEGRATION_DEST=1 CONTAINER_NAME=${CONTAINER_NAME}-1 TEST_SKIP_INTEGRATION_CLI=1 run_tests test-integration-flaky &
   332  
   333                                  # integration-cli first set
   334                                  TEST_INTEGRATION_DEST=2 CONTAINER_NAME=${CONTAINER_NAME}-2 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run Test(DockerSuite|DockerNetworkSuite|DockerHubPullSuite|DockerRegistrySuite|DockerSchema1RegistrySuite|DockerRegistryAuthTokenSuite|DockerRegistryAuthHtpasswdSuite)/" run_tests &
   335  
   336                                  # integration-cli second set
   337                                  TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run Test(DockerSwarmSuite|DockerDaemonSuite|DockerExternalVolumeSuite)/" run_tests &
   338  
   339                                  c=0
   340                                  for job in $(jobs -p); do
   341                                          wait ${job} || c=$?
   342                                  done
   343                                  exit $c
   344                                  '''
   345                              }
   346                              post {
   347                                  always {
   348                                      junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
   349                                  }
   350                              }
   351                          }
   352                      }
   353  
   354                      post {
   355                          always {
   356                              sh '''
   357                              echo "Ensuring container killed."
   358                              cids=$(docker ps -aq -f name=docker-pr${BUILD_NUMBER}-*)
   359                              [ -n "$cids" ] && docker rm -vf $cids || true
   360                              '''
   361  
   362                              sh '''
   363                              echo "Chowning /workspace to jenkins user"
   364                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   365                              '''
   366  
   367                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   368                                  sh '''
   369                                  bundleName=amd64
   370                                  echo "Creating ${bundleName}-bundles.tar.gz"
   371                                  # exclude overlay2 directories
   372                                  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
   373                                  '''
   374  
   375                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   376                              }
   377                          }
   378                          cleanup {
   379                              sh 'make clean'
   380                              deleteDir()
   381                          }
   382                      }
   383                  }
   384                  stage('rootless') {
   385                      when {
   386                          beforeAgent true
   387                          expression { params.rootless }
   388                      }
   389                      agent { label 'amd64 && ubuntu-1804 && overlay2' }
   390                      stages {
   391                          stage("Print info") {
   392                              steps {
   393                                  sh 'docker version'
   394                                  sh 'docker info'
   395                                  sh '''
   396                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
   397                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
   398                                  && bash ${WORKSPACE}/check-config.sh || true
   399                                  '''
   400                              }
   401                          }
   402                          stage("Build dev image") {
   403                              steps {
   404                                  sh '''
   405                                  docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
   406                                  '''
   407                              }
   408                          }
   409                          stage("Integration tests") {
   410                              environment {
   411                                  DOCKER_ROOTLESS = '1'
   412                                  TEST_SKIP_INTEGRATION_CLI = '1'
   413                              }
   414                              steps {
   415                                  sh '''
   416                                  docker run --rm -t --privileged \
   417                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   418                                    --name docker-pr$BUILD_NUMBER \
   419                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   420                                    -e DOCKER_GRAPHDRIVER \
   421                                    -e DOCKER_EXPERIMENTAL \
   422                                    -e DOCKER_ROOTLESS \
   423                                    -e TEST_SKIP_INTEGRATION_CLI \
   424                                    -e TIMEOUT \
   425                                    -e VALIDATE_REPO=${GIT_URL} \
   426                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   427                                    docker:${GIT_COMMIT} \
   428                                    hack/make.sh \
   429                                      dynbinary \
   430                                      test-integration
   431                                  '''
   432                              }
   433                              post {
   434                                  always {
   435                                      junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
   436                                  }
   437                              }
   438                          }
   439                      }
   440  
   441                      post {
   442                          always {
   443                              sh '''
   444                              echo "Ensuring container killed."
   445                              docker rm -vf docker-pr$BUILD_NUMBER || true
   446                              '''
   447  
   448                              sh '''
   449                              echo "Chowning /workspace to jenkins user"
   450                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   451                              '''
   452  
   453                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   454                                  sh '''
   455                                  bundleName=amd64-rootless
   456                                  echo "Creating ${bundleName}-bundles.tar.gz"
   457                                  # exclude overlay2 directories
   458                                  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
   459                                  '''
   460  
   461                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   462                              }
   463                          }
   464                          cleanup {
   465                              sh 'make clean'
   466                              deleteDir()
   467                          }
   468                      }
   469                  }
   470  
   471                  stage('s390x') {
   472                      when {
   473                          beforeAgent true
   474                          expression { params.s390x }
   475                      }
   476                      agent { label 's390x-ubuntu-1804' }
   477  
   478                      stages {
   479                          stage("Print info") {
   480                              steps {
   481                                  sh 'docker version'
   482                                  sh 'docker info'
   483                                  sh '''
   484                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
   485                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
   486                                  && bash ${WORKSPACE}/check-config.sh || true
   487                                  '''
   488                              }
   489                          }
   490                          stage("Build dev image") {
   491                              steps {
   492                                  sh '''
   493                                  docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
   494                                  '''
   495                              }
   496                          }
   497                          stage("Unit tests") {
   498                              steps {
   499                                  sh '''
   500                                  docker run --rm -t --privileged \
   501                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   502                                    --name docker-pr$BUILD_NUMBER \
   503                                    -e DOCKER_EXPERIMENTAL \
   504                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   505                                    -e DOCKER_GRAPHDRIVER \
   506                                    -e VALIDATE_REPO=${GIT_URL} \
   507                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   508                                    docker:${GIT_COMMIT} \
   509                                    hack/test/unit
   510                                  '''
   511                              }
   512                              post {
   513                                  always {
   514                                      junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true
   515                                  }
   516                              }
   517                          }
   518                          stage("Integration tests") {
   519                              environment { TEST_SKIP_INTEGRATION_CLI = '1' }
   520                              steps {
   521                                  sh '''
   522                                  docker run --rm -t --privileged \
   523                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   524                                    --name docker-pr$BUILD_NUMBER \
   525                                    -e DOCKER_EXPERIMENTAL \
   526                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   527                                    -e DOCKER_GRAPHDRIVER \
   528                                    -e TESTDEBUG \
   529                                    -e TEST_SKIP_INTEGRATION_CLI \
   530                                    -e TIMEOUT \
   531                                    -e VALIDATE_REPO=${GIT_URL} \
   532                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   533                                    docker:${GIT_COMMIT} \
   534                                    hack/make.sh \
   535                                      dynbinary \
   536                                      test-integration
   537                                  '''
   538                              }
   539                              post {
   540                                  always {
   541                                      junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
   542                                  }
   543                              }
   544                          }
   545                      }
   546  
   547                      post {
   548                          always {
   549                              sh '''
   550                              echo "Ensuring container killed."
   551                              docker rm -vf docker-pr$BUILD_NUMBER || true
   552                              '''
   553  
   554                              sh '''
   555                              echo "Chowning /workspace to jenkins user"
   556                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   557                              '''
   558  
   559                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   560                                  sh '''
   561                                  bundleName=s390x-integration
   562                                  echo "Creating ${bundleName}-bundles.tar.gz"
   563                                  # exclude overlay2 directories
   564                                  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
   565                                  '''
   566  
   567                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   568                              }
   569                          }
   570                          cleanup {
   571                              sh 'make clean'
   572                              deleteDir()
   573                          }
   574                      }
   575                  }
   576                  stage('s390x integration-cli') {
   577                      when {
   578                          beforeAgent true
   579                          not { changeRequest() }
   580                          expression { params.s390x }
   581                      }
   582                      agent { label 's390x-ubuntu-1804' }
   583  
   584                      stages {
   585                          stage("Print info") {
   586                              steps {
   587                                  sh 'docker version'
   588                                  sh 'docker info'
   589                                  sh '''
   590                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
   591                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
   592                                  && bash ${WORKSPACE}/check-config.sh || true
   593                                  '''
   594                              }
   595                          }
   596                          stage("Build dev image") {
   597                              steps {
   598                                  sh '''
   599                                  docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
   600                                  '''
   601                              }
   602                          }
   603                          stage("Integration-cli tests") {
   604                              environment { TEST_SKIP_INTEGRATION = '1' }
   605                              steps {
   606                                  sh '''
   607                                  docker run --rm -t --privileged \
   608                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   609                                    --name docker-pr$BUILD_NUMBER \
   610                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   611                                    -e DOCKER_GRAPHDRIVER \
   612                                    -e TEST_SKIP_INTEGRATION \
   613                                    -e TIMEOUT \
   614                                    -e VALIDATE_REPO=${GIT_URL} \
   615                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   616                                    docker:${GIT_COMMIT} \
   617                                    hack/make.sh \
   618                                      dynbinary \
   619                                      test-integration
   620                                  '''
   621                              }
   622                              post {
   623                                  always {
   624                                      junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
   625                                  }
   626                              }
   627                          }
   628                      }
   629  
   630                      post {
   631                          always {
   632                              sh '''
   633                              echo "Ensuring container killed."
   634                              docker rm -vf docker-pr$BUILD_NUMBER || true
   635                              '''
   636  
   637                              sh '''
   638                              echo "Chowning /workspace to jenkins user"
   639                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   640                              '''
   641  
   642                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   643                                  sh '''
   644                                  bundleName=s390x-integration-cli
   645                                  echo "Creating ${bundleName}-bundles.tar.gz"
   646                                  # exclude overlay2 directories
   647                                  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
   648                                  '''
   649  
   650                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   651                              }
   652                          }
   653                          cleanup {
   654                              sh 'make clean'
   655                              deleteDir()
   656                          }
   657                      }
   658                  }
   659                  stage('ppc64le') {
   660                      when {
   661                          beforeAgent true
   662                          expression { params.ppc64le }
   663                      }
   664                      agent { label 'ppc64le-ubuntu-1604' }
   665                      // ppc64le machines run on Docker 18.06, and buildkit has some
   666                      // bugs on that version. Build and use buildx instead.
   667                      environment {
   668                          USE_BUILDX      = '1'
   669                          DOCKER_BUILDKIT = '0'
   670                      }
   671  
   672                      stages {
   673                          stage("Print info") {
   674                              steps {
   675                                  sh 'docker version'
   676                                  sh 'docker info'
   677                                  sh '''
   678                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
   679                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
   680                                  && bash ${WORKSPACE}/check-config.sh || true
   681                                  '''
   682                              }
   683                          }
   684                          stage("Build dev image") {
   685                              steps {
   686                                  sh '''
   687                                  make bundles/buildx
   688                                  bundles/buildx build --load --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
   689                                  '''
   690                              }
   691                          }
   692                          stage("Unit tests") {
   693                              steps {
   694                                  sh '''
   695                                  docker run --rm -t --privileged \
   696                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   697                                    --name docker-pr$BUILD_NUMBER \
   698                                    -e DOCKER_EXPERIMENTAL \
   699                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   700                                    -e DOCKER_GRAPHDRIVER \
   701                                    -e VALIDATE_REPO=${GIT_URL} \
   702                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   703                                    docker:${GIT_COMMIT} \
   704                                    hack/test/unit
   705                                  '''
   706                              }
   707                              post {
   708                                  always {
   709                                      junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true
   710                                  }
   711                              }
   712                          }
   713                          stage("Integration tests") {
   714                              environment { TEST_SKIP_INTEGRATION_CLI = '1' }
   715                              steps {
   716                                  sh '''
   717                                  docker run --rm -t --privileged \
   718                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   719                                    --name docker-pr$BUILD_NUMBER \
   720                                    -e DOCKER_EXPERIMENTAL \
   721                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   722                                    -e DOCKER_GRAPHDRIVER \
   723                                    -e TESTDEBUG \
   724                                    -e TEST_SKIP_INTEGRATION_CLI \
   725                                    -e TIMEOUT \
   726                                    -e VALIDATE_REPO=${GIT_URL} \
   727                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   728                                    docker:${GIT_COMMIT} \
   729                                    hack/make.sh \
   730                                      dynbinary \
   731                                      test-integration
   732                                  '''
   733                              }
   734                              post {
   735                                  always {
   736                                      junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
   737                                  }
   738                              }
   739                          }
   740                      }
   741  
   742                      post {
   743                          always {
   744                              sh '''
   745                              echo "Ensuring container killed."
   746                              docker rm -vf docker-pr$BUILD_NUMBER || true
   747                              '''
   748  
   749                              sh '''
   750                              echo "Chowning /workspace to jenkins user"
   751                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   752                              '''
   753  
   754                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   755                                  sh '''
   756                                  bundleName=ppc64le-integration
   757                                  echo "Creating ${bundleName}-bundles.tar.gz"
   758                                  # exclude overlay2 directories
   759                                  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
   760                                  '''
   761  
   762                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   763                              }
   764                          }
   765                          cleanup {
   766                              sh 'make clean'
   767                              deleteDir()
   768                          }
   769                      }
   770                  }
   771                  stage('ppc64le integration-cli') {
   772                      when {
   773                          beforeAgent true
   774                          not { changeRequest() }
   775                          expression { params.ppc64le }
   776                      }
   777                      agent { label 'ppc64le-ubuntu-1604' }
   778                      // ppc64le machines run on Docker 18.06, and buildkit has some
   779                      // bugs on that version. Build and use buildx instead.
   780                      environment {
   781                          USE_BUILDX      = '1'
   782                          DOCKER_BUILDKIT = '0'
   783                      }
   784  
   785                      stages {
   786                          stage("Print info") {
   787                              steps {
   788                                  sh 'docker version'
   789                                  sh 'docker info'
   790                                  sh '''
   791                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
   792                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
   793                                  && bash ${WORKSPACE}/check-config.sh || true
   794                                  '''
   795                              }
   796                          }
   797                          stage("Build dev image") {
   798                              steps {
   799                                  sh '''
   800                                  make bundles/buildx
   801                                  bundles/buildx build --load --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .
   802                                  '''
   803                              }
   804                          }
   805                          stage("Integration-cli tests") {
   806                              environment { TEST_SKIP_INTEGRATION = '1' }
   807                              steps {
   808                                  sh '''
   809                                  docker run --rm -t --privileged \
   810                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   811                                    --name docker-pr$BUILD_NUMBER \
   812                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   813                                    -e DOCKER_GRAPHDRIVER \
   814                                    -e TEST_SKIP_INTEGRATION \
   815                                    -e TIMEOUT \
   816                                    -e VALIDATE_REPO=${GIT_URL} \
   817                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   818                                    docker:${GIT_COMMIT} \
   819                                    hack/make.sh \
   820                                      dynbinary \
   821                                      test-integration
   822                                  '''
   823                              }
   824                              post {
   825                                  always {
   826                                      junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
   827                                  }
   828                              }
   829                          }
   830                      }
   831  
   832                      post {
   833                          always {
   834                              sh '''
   835                              echo "Ensuring container killed."
   836                              docker rm -vf docker-pr$BUILD_NUMBER || true
   837                              '''
   838  
   839                              sh '''
   840                              echo "Chowning /workspace to jenkins user"
   841                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   842                              '''
   843  
   844                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   845                                  sh '''
   846                                  bundleName=ppc64le-integration-cli
   847                                  echo "Creating ${bundleName}-bundles.tar.gz"
   848                                  # exclude overlay2 directories
   849                                  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
   850                                  '''
   851  
   852                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   853                              }
   854                          }
   855                          cleanup {
   856                              sh 'make clean'
   857                              deleteDir()
   858                          }
   859                      }
   860                  }
   861                  stage('arm64') {
   862                      when {
   863                          beforeAgent true
   864                          expression { params.arm64 }
   865                      }
   866                      agent { label 'arm64 && linux' }
   867                      environment {
   868                          TEST_SKIP_INTEGRATION_CLI = '1'
   869                      }
   870  
   871                      stages {
   872                          stage("Print info") {
   873                              steps {
   874                                  sh 'docker version'
   875                                  sh 'docker info'
   876                                  sh '''
   877                                  echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
   878                                  curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
   879                                  && bash ${WORKSPACE}/check-config.sh || true
   880                                  '''
   881                              }
   882                          }
   883                          stage("Build dev image") {
   884                              steps {
   885                                  sh 'docker build --force-rm --build-arg APT_MIRROR -t docker:${GIT_COMMIT} .'
   886                              }
   887                          }
   888                          stage("Unit tests") {
   889                              steps {
   890                                  sh '''
   891                                  docker run --rm -t --privileged \
   892                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   893                                    --name docker-pr$BUILD_NUMBER \
   894                                    -e DOCKER_EXPERIMENTAL \
   895                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   896                                    -e DOCKER_GRAPHDRIVER \
   897                                    -e VALIDATE_REPO=${GIT_URL} \
   898                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   899                                    docker:${GIT_COMMIT} \
   900                                    hack/test/unit
   901                                  '''
   902                              }
   903                              post {
   904                                  always {
   905                                      junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true
   906                                  }
   907                              }
   908                          }
   909                          stage("Integration tests") {
   910                              environment { TEST_SKIP_INTEGRATION_CLI = '1' }
   911                              steps {
   912                                  sh '''
   913                                  docker run --rm -t --privileged \
   914                                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   915                                    --name docker-pr$BUILD_NUMBER \
   916                                    -e DOCKER_EXPERIMENTAL \
   917                                    -e DOCKER_GITCOMMIT=${GIT_COMMIT} \
   918                                    -e DOCKER_GRAPHDRIVER \
   919                                    -e TESTDEBUG \
   920                                    -e TEST_SKIP_INTEGRATION_CLI \
   921                                    -e TIMEOUT \
   922                                    -e VALIDATE_REPO=${GIT_URL} \
   923                                    -e VALIDATE_BRANCH=${CHANGE_TARGET} \
   924                                    docker:${GIT_COMMIT} \
   925                                    hack/make.sh \
   926                                      dynbinary \
   927                                      test-integration
   928                                  '''
   929                              }
   930                              post {
   931                                  always {
   932                                      junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
   933                                  }
   934                              }
   935                          }
   936                      }
   937  
   938                      post {
   939                          always {
   940                              sh '''
   941                              echo "Ensuring container killed."
   942                              docker rm -vf docker-pr$BUILD_NUMBER || true
   943                              '''
   944  
   945                              sh '''
   946                              echo "Chowning /workspace to jenkins user"
   947                              docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   948                              '''
   949  
   950                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
   951                                  sh '''
   952                                  bundleName=arm64-integration
   953                                  echo "Creating ${bundleName}-bundles.tar.gz"
   954                                  # exclude overlay2 directories
   955                                  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
   956                                  '''
   957  
   958                                  archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
   959                              }
   960                          }
   961                          cleanup {
   962                              sh 'make clean'
   963                              deleteDir()
   964                          }
   965                      }
   966                  }
   967                  stage('win-RS1') {
   968                      when {
   969                          beforeAgent true
   970                          // Skip this stage on PRs unless the windowsRS1 checkbox is selected
   971                          anyOf {
   972                              not { changeRequest() }
   973                              expression { params.windowsRS1 }
   974                          }
   975                      }
   976                      environment {
   977                          DOCKER_BUILDKIT        = '0'
   978                          DOCKER_DUT_DEBUG       = '1'
   979                          SKIP_VALIDATION_TESTS  = '1'
   980                          SOURCES_DRIVE          = 'd'
   981                          SOURCES_SUBDIR         = 'gopath'
   982                          TESTRUN_DRIVE          = 'd'
   983                          TESTRUN_SUBDIR         = "CI"
   984                          WINDOWS_BASE_IMAGE     = 'mcr.microsoft.com/windows/servercore'
   985                          WINDOWS_BASE_IMAGE_TAG = 'ltsc2016'
   986                      }
   987                      agent {
   988                          node {
   989                              customWorkspace 'd:\\gopath\\src\\github.com\\docker\\docker'
   990                              label 'windows-2016'
   991                          }
   992                      }
   993                      stages {
   994                          stage("Print info") {
   995                              steps {
   996                                  sh 'docker version'
   997                                  sh 'docker info'
   998                              }
   999                          }
  1000                          stage("Run tests") {
  1001                              steps {
  1002                                  powershell '''
  1003                                  $ErrorActionPreference = 'Stop'
  1004                                  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  1005                                  Invoke-WebRequest https://github.com/moby/docker-ci-zap/blob/master/docker-ci-zap.exe?raw=true -OutFile C:/Windows/System32/docker-ci-zap.exe
  1006                                  ./hack/ci/windows.ps1
  1007                                  exit $LastExitCode
  1008                                  '''
  1009                              }
  1010                          }
  1011                      }
  1012                      post {
  1013                          always {
  1014                              junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true
  1015                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  1016                                  powershell '''
  1017                                  $bundleName="windowsRS1-integration"
  1018                                  Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
  1019  
  1020                                  # archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
  1021                                  Compress-Archive -Path "${env:TEMP}/CIDUT.out", "${env:TEMP}/CIDUT.err", "${env:TEMP}/testresults/unittests/junit-report-unit-tests.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
  1022                                  '''
  1023  
  1024                                  archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true
  1025                              }
  1026                          }
  1027                          cleanup {
  1028                              sh 'make clean'
  1029                              deleteDir()
  1030                          }
  1031                      }
  1032                  }
  1033                  stage('win-RS5') {
  1034                      when {
  1035                          beforeAgent true
  1036                          expression { params.windowsRS5 }
  1037                      }
  1038                      environment {
  1039                          DOCKER_BUILDKIT        = '0'
  1040                          DOCKER_DUT_DEBUG       = '1'
  1041                          SKIP_VALIDATION_TESTS  = '1'
  1042                          SOURCES_DRIVE          = 'd'
  1043                          SOURCES_SUBDIR         = 'gopath'
  1044                          TESTRUN_DRIVE          = 'd'
  1045                          TESTRUN_SUBDIR         = "CI"
  1046                          WINDOWS_BASE_IMAGE     = 'mcr.microsoft.com/windows/servercore'
  1047                          WINDOWS_BASE_IMAGE_TAG = 'ltsc2019'
  1048                      }
  1049                      agent {
  1050                          node {
  1051                              customWorkspace 'd:\\gopath\\src\\github.com\\docker\\docker'
  1052                              label 'windows-2019'
  1053                          }
  1054                      }
  1055                      stages {
  1056                          stage("Print info") {
  1057                              steps {
  1058                                  sh 'docker version'
  1059                                  sh 'docker info'
  1060                              }
  1061                          }
  1062                          stage("Run tests") {
  1063                              steps {
  1064                                  powershell '''
  1065                                  $ErrorActionPreference = 'Stop'
  1066                                  Invoke-WebRequest https://github.com/moby/docker-ci-zap/blob/master/docker-ci-zap.exe?raw=true -OutFile C:/Windows/System32/docker-ci-zap.exe
  1067                                  ./hack/ci/windows.ps1
  1068                                  exit $LastExitCode
  1069                                  '''
  1070                              }
  1071                          }
  1072                      }
  1073                      post {
  1074                          always {
  1075                              junit testResults: 'bundles/junit-report-*.xml', allowEmptyResults: true
  1076                              catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
  1077                                  powershell '''
  1078                                  $bundleName="windowsRS5-integration"
  1079                                  Write-Host -ForegroundColor Green "Creating ${bundleName}-bundles.zip"
  1080  
  1081                                  # archiveArtifacts does not support env-vars to , so save the artifacts in a fixed location
  1082                                  Compress-Archive -Path "${env:TEMP}/CIDUT.out", "${env:TEMP}/CIDUT.err", "${env:TEMP}/junit-report-*.xml" -CompressionLevel Optimal -DestinationPath "${bundleName}-bundles.zip"
  1083                                  '''
  1084  
  1085                                  archiveArtifacts artifacts: '*-bundles.zip', allowEmptyArchive: true
  1086                              }
  1087                          }
  1088                          cleanup {
  1089                              sh 'make clean'
  1090                              deleteDir()
  1091                          }
  1092                      }
  1093                  }
  1094              }
  1095          }
  1096      }
  1097  }