github.com/status-im/status-go@v1.1.0/_assets/ci/Jenkinsfile.docker (about)

     1  #!/usr/bin/env groovy
     2  library 'status-jenkins-lib@v1.9.6'
     3  
     4  pipeline {
     5    agent { label 'linux' }
     6  
     7    parameters {
     8      string(
     9        name: 'BRANCH',
    10        defaultValue: 'develop',
    11        description: 'Name of branch to build.'
    12      )
    13      booleanParam(
    14        name: 'RELEASE',
    15        defaultValue: false,
    16        description: 'Enable to create build for release.',
    17      )
    18      string(
    19        name: 'RELEASE_IMAGE_TAG',
    20        description: 'Release Docker image tag.',
    21        defaultValue: params.RELEASE_IMAGE_TAG ?: 'deploy-test',
    22      )
    23    }
    24  
    25    options {
    26      timestamps()
    27      /* Prevent Jenkins jobs from running forever */
    28      timeout(time: 10, unit: 'MINUTES')
    29      disableConcurrentBuilds()
    30      /* Go requires a certain directory structure */
    31      checkoutToSubdirectory('src/github.com/status-im/status-go')
    32      /* manage how many builds we keep */
    33      buildDiscarder(logRotator(
    34        numToKeepStr: '5',
    35        daysToKeepStr: '30',
    36        artifactNumToKeepStr: '1',
    37      ))
    38    }
    39  
    40    environment {
    41      PLATFORM = "docker"
    42      REPO     = "${env.WORKSPACE}/src/github.com/status-im/status-go"
    43      GOPATH   = "${env.WORKSPACE}"
    44      GOCACHE  = "${WORKSPACE_TMP}/gocache"
    45      PATH     = "/usr/local/go/bin:${env.PATH}:${env.GOPATH}/bin"
    46      /* Makefile parameters */
    47      DOCKER_IMAGE_NAME = 'statusteam/status-go'
    48      DOCKER_IMAGE_CUSTOM_TAG = "ci-build-${git.commit()}"
    49    }
    50  
    51    stages {
    52      stage('Prep') { steps { dir(env.REPO) { script {
    53        println("Output: ${env.DOCKER_IMAGE_NAME}:${env.RELEASE_IMAGE_TAG}")
    54      } } } }
    55  
    56      stage('Build') { steps { dir(env.REPO) { script {
    57        sh 'make docker-image'
    58        image = docker.image("${env.DOCKER_IMAGE_NAME}:${env.DOCKER_IMAGE_CUSTOM_TAG}")
    59      } } } }
    60  
    61      stage('Push') { steps { dir(env.REPO) { script {
    62        withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
    63          image.push("v${utils.getVersion()}-${git.commit()}")
    64        }
    65      } } } }
    66  
    67      stage('Deploy') {
    68        when { expression { params.RELEASE == true } }
    69        steps { dir(env.REPO) { script {
    70          withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) {
    71            image.push(env.RELEASE_IMAGE_TAG)
    72          }
    73      } } } }
    74    } // stages
    75    post {
    76      success { script { github.notifyPR(true) } }
    77      failure { script { github.notifyPR(false) } }
    78      always  { dir(env.REPO) {
    79        sh 'make clean-docker-images'
    80      } }
    81    } // post
    82  } // pipeline