github.com/jwhonce/docker@v0.6.7-0.20190327063223-da823cf3a5a3/Jenkinsfile (about)

     1  def withGithubStatus(String context, Closure cl) {
     2    def setGithubStatus = { String state ->
     3      try {
     4        def backref = "${BUILD_URL}flowGraphTable/"
     5        def reposSourceURL = scm.repositories[0].getURIs()[0].toString()
     6        step(
     7          $class: 'GitHubCommitStatusSetter',
     8          contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
     9          errorHandlers: [[$class: 'ShallowAnyErrorHandler']],
    10          reposSource: [$class: 'ManuallyEnteredRepositorySource', url: reposSourceURL],
    11          statusBackrefSource: [$class: 'ManuallyEnteredBackrefSource', backref: backref],
    12          statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', state: state]]],
    13        )
    14      } catch (err) {
    15        echo "Exception from GitHubCommitStatusSetter for $context: $err"
    16      }
    17    }
    18  
    19    setGithubStatus 'PENDING'
    20  
    21    try {
    22      cl()
    23  	} catch (err) {
    24      // AbortException signals a "normal" build failure.
    25      if (!(err instanceof hudson.AbortException)) {
    26        echo "Exception in withGithubStatus for $context: $err"
    27  		}
    28  		setGithubStatus 'FAILURE'
    29  		throw err
    30  	}
    31  	setGithubStatus 'SUCCESS'
    32  }
    33  
    34  
    35  pipeline {
    36    agent none
    37    options {
    38      buildDiscarder(logRotator(daysToKeepStr: '30'))
    39      timeout(time: 3, unit: 'HOURS')
    40    }
    41    parameters {
    42          booleanParam(name: 'janky', defaultValue: true, description: 'x86 Build/Test')
    43          booleanParam(name: 'experimental', defaultValue: true, description: 'x86 Experimental Build/Test ')
    44          booleanParam(name: 'z', defaultValue: true, description: 'IBM Z (s390x) Build/Test')
    45          booleanParam(name: 'powerpc', defaultValue: true, description: 'PowerPC (ppc64le) Build/Test')
    46          booleanParam(name: 'vendor', defaultValue: true, description: 'Vendor')
    47          booleanParam(name: 'windowsRS1', defaultValue: true, description: 'Windows 2016 (RS1) Build/Test')
    48          booleanParam(name: 'windowsRS5', defaultValue: true, description: 'Windows 2019 (RS5) Build/Test')
    49    }
    50    stages {
    51      stage('Build') {
    52        parallel {
    53          stage('janky') {
    54            when {
    55              beforeAgent true
    56              expression { params.janky }
    57            }
    58            agent {
    59              node {
    60                label 'ubuntu-1604-overlay2-stable'
    61              }
    62            }
    63            steps {
    64              withCredentials([string(credentialsId: '52af932f-f13f-429e-8467-e7ff8b965cdb', variable: 'CODECOV_TOKEN')]) {
    65                withGithubStatus('janky') {
    66                  sh '''
    67                    # todo: include ip_vs in base image
    68                    sudo modprobe ip_vs
    69  
    70                    GITCOMMIT=$(git rev-parse --short HEAD)
    71                    docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t docker:$GITCOMMIT .
    72  
    73                    docker run --rm -t --privileged \
    74                      -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
    75                      -v "$WORKSPACE/.git:/go/src/github.com/docker/docker/.git" \
    76                      --name docker-pr$BUILD_NUMBER \
    77                      -e DOCKER_GITCOMMIT=${GITCOMMIT} \
    78                      -e DOCKER_GRAPHDRIVER=vfs \
    79                      -e DOCKER_EXECDRIVER=native \
    80                      -e CODECOV_TOKEN \
    81                      -e GIT_SHA1=${GIT_COMMIT} \
    82                      docker:$GITCOMMIT \
    83                      hack/ci/janky
    84                  '''
    85                  sh '''
    86                    GITCOMMIT=$(git rev-parse --short HEAD)
    87                    echo "Building e2e image"
    88                    docker build --build-arg DOCKER_GITCOMMIT=$GITCOMMIT -t moby-e2e-test -f Dockerfile.e2e .
    89                  '''
    90                }
    91              }
    92            }
    93            post {
    94              always {
    95                sh '''
    96                  echo "Ensuring container killed."
    97                  docker rm -vf docker-pr$BUILD_NUMBER || true
    98  
    99                  echo "Chowning /workspace to jenkins user"
   100                  docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   101                '''
   102                sh '''
   103                  echo "Creating bundles.tar.gz"
   104                  (find bundles -name '*.log' -o -name '*.prof' -o -name integration.test | xargs tar -czf bundles.tar.gz) || true
   105                '''
   106                archiveArtifacts artifacts: 'bundles.tar.gz'
   107              }
   108            }
   109          }
   110          stage('experimental') {
   111            when {
   112              beforeAgent true
   113              expression { params.experimental }
   114            }
   115            agent {
   116              node {
   117                label 'ubuntu-1604-aufs-stable'
   118              }
   119            }
   120            steps {
   121              withGithubStatus('experimental') {
   122                sh '''
   123                  GITCOMMIT=$(git rev-parse --short HEAD)
   124                  docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t docker:${GITCOMMIT}-exp .
   125  
   126                  docker run --rm -t --privileged \
   127                      -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   128                      -e DOCKER_EXPERIMENTAL=y \
   129                      --name docker-pr-exp$BUILD_NUMBER \
   130                      -e DOCKER_GITCOMMIT=${GITCOMMIT} \
   131                      -e DOCKER_GRAPHDRIVER=vfs \
   132                      -e DOCKER_EXECDRIVER=native \
   133                      docker:${GITCOMMIT}-exp \
   134                      hack/ci/experimental
   135                '''
   136              }
   137            }
   138            post {
   139              always {
   140                sh '''
   141                  echo "Ensuring container killed."
   142                  docker rm -vf docker-pr-exp$BUILD_NUMBER || true
   143  
   144                  echo "Chowning /workspace to jenkins user"
   145                  docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
   146                '''
   147                sh '''
   148                  echo "Creating bundles.tar.gz"
   149                  (find bundles -name '*.log' -o -name '*.prof' -o -name integration.test | xargs tar -czf bundles.tar.gz) || true
   150                '''
   151                archiveArtifacts artifacts: 'bundles.tar.gz'
   152              }
   153            }
   154          }
   155          stage('z') {
   156            when {
   157              beforeAgent true
   158              expression { params.z }
   159            }
   160            agent {
   161              node {
   162                label 's390x-ubuntu-1604'
   163              }
   164            }
   165            steps {
   166              withGithubStatus('z') {
   167                sh '''
   168                  GITCOMMIT=$(git rev-parse --short HEAD)
   169  
   170                  test -f Dockerfile.s390x && \
   171                  docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t docker-s390x:$GITCOMMIT -f Dockerfile.s390x . || \
   172                  docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t docker-s390x:$GITCOMMIT -f Dockerfile .
   173  
   174                  docker run --rm -t --privileged \
   175                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   176                      --name docker-pr-s390x$BUILD_NUMBER \
   177                      -e DOCKER_GRAPHDRIVER=vfs \
   178                      -e DOCKER_EXECDRIVER=native \
   179                      -e TIMEOUT="300m" \
   180                      -e DOCKER_GITCOMMIT=${GITCOMMIT} \
   181                      docker-s390x:$GITCOMMIT \
   182                      hack/ci/z
   183                '''
   184              }
   185            }
   186            post {
   187              always {
   188                sh '''
   189                  echo "Ensuring container killed."
   190                  docker rm -vf docker-pr-s390x$BUILD_NUMBER || true
   191  
   192                  echo "Chowning /workspace to jenkins user"
   193                  docker run --rm -v "$WORKSPACE:/workspace" s390x/busybox chown -R "$(id -u):$(id -g)" /workspace
   194                '''
   195                sh '''
   196                  echo "Creating bundles.tar.gz"
   197                  find bundles -name '*.log' | xargs tar -czf bundles.tar.gz
   198                '''
   199                archiveArtifacts artifacts: 'bundles.tar.gz'
   200              }
   201            }
   202          }
   203          stage('powerpc') {
   204            when {
   205              beforeAgent true
   206              expression { params.powerpc }
   207            }
   208            agent {
   209              node {
   210                label 'ppc64le-ubuntu-1604'
   211              }
   212            }
   213            steps {
   214              withGithubStatus('powerpc') {
   215                sh '''
   216                  GITCOMMIT=$(git rev-parse --short HEAD)
   217  
   218                  test -f Dockerfile.ppc64le && \
   219                  docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t docker-powerpc:$GITCOMMIT -f Dockerfile.ppc64le . || \
   220                  docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t docker-powerpc:$GITCOMMIT -f Dockerfile .
   221  
   222                  docker run --rm -t --privileged \
   223                    -v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
   224                      --name docker-pr-power$BUILD_NUMBER \
   225                      -e DOCKER_GRAPHDRIVER=vfs \
   226                      -e DOCKER_EXECDRIVER=native \
   227                      -e DOCKER_GITCOMMIT=${GITCOMMIT} \
   228                      -e TIMEOUT="180m" \
   229                      docker-powerpc:$GITCOMMIT \
   230                      hack/ci/powerpc
   231                '''
   232              }
   233            }
   234            post {
   235              always {
   236                sh '''
   237                  echo "Ensuring container killed."
   238                  docker rm -vf docker-pr-power$BUILD_NUMBER || true
   239  
   240                  echo "Chowning /workspace to jenkins user"
   241                  docker run --rm -v "$WORKSPACE:/workspace" ppc64le/busybox chown -R "$(id -u):$(id -g)" /workspace
   242                '''
   243                sh '''
   244                  echo "Creating bundles.tar.gz"
   245                  find bundles -name '*.log' | xargs tar -czf bundles.tar.gz
   246                '''
   247                archiveArtifacts artifacts: 'bundles.tar.gz'
   248              }
   249            }
   250          }
   251          stage('vendor') {
   252            when {
   253              beforeAgent true
   254              expression { params.vendor }
   255            }
   256            agent {
   257              node {
   258                label 'ubuntu-1604-aufs-stable'
   259              }
   260            }
   261            steps {
   262              withGithubStatus('vendor') {
   263                sh '''
   264                  GITCOMMIT=$(git rev-parse --short HEAD)
   265  
   266                  docker build --rm --force-rm --build-arg APT_MIRROR=cdn-fastly.deb.debian.org -t dockerven:$GITCOMMIT .
   267  
   268                  docker run --rm -t --privileged \
   269                    --name dockerven-pr$BUILD_NUMBER \
   270                    -e DOCKER_GRAPHDRIVER=vfs \
   271                    -e DOCKER_EXECDRIVER=native \
   272                    -v "$WORKSPACE/.git:/go/src/github.com/docker/docker/.git" \
   273                    -e DOCKER_GITCOMMIT=${GITCOMMIT} \
   274                    -e TIMEOUT=120m dockerven:$GITCOMMIT \
   275                    hack/validate/vendor
   276                '''
   277              }
   278            }
   279          }
   280          stage('windowsRS1') {
   281            when {
   282              beforeAgent true
   283              expression { params.windowsRS1 }
   284            }
   285            agent {
   286              node {
   287                label 'windows-rs1'
   288                customWorkspace 'c:\\gopath\\src\\github.com\\docker\\docker'
   289              }
   290            }
   291            steps {
   292              withGithubStatus('windowsRS1') {
   293                powershell '''
   294                  $ErrorActionPreference = 'Stop'
   295                  .\\hack\\ci\\windows.ps1
   296                  exit $LastExitCode
   297                '''
   298              }
   299            }
   300          }
   301          stage('windowsRS5-process') {
   302            when {
   303              beforeAgent true
   304              expression { params.windowsRS5 }
   305            }
   306            agent {
   307              node {
   308                label 'windows-rs5'
   309                customWorkspace 'c:\\gopath\\src\\github.com\\docker\\docker'
   310              }
   311            }
   312            steps {
   313              withGithubStatus('windowsRS5-process') {
   314                powershell '''
   315                  $ErrorActionPreference = 'Stop'
   316                  .\\hack\\ci\\windows.ps1
   317                  exit $LastExitCode
   318                '''
   319              }
   320            }
   321          }
   322        }
   323      }
   324    }
   325  }