/ Jenkinsfile
Jenkinsfile
 1  #!/usr/bin/env groovy
 2  library 'status-jenkins-lib@v1.9.24'
 3  
 4  pipeline {
 5    agent {
 6      docker {
 7        label 'linuxcontainer'
 8        image 'harbor.status.im/infra/ci-build-containers:linux-base-1.0.0'
 9        args '--volume=/nix:/nix ' +
10             '--volume=/etc/nix:/etc/nix ' +
11             '--user jenkins'
12      }
13    }
14  
15    options {
16      disableConcurrentBuilds()
17      /* manage how many builds we keep */
18      buildDiscarder(logRotator(
19        numToKeepStr: '20',
20        daysToKeepStr: '30',
21      ))
22    }
23  
24    environment {
25      GIT_COMMITTER_NAME = 'status-im-auto'
26      GIT_COMMITTER_EMAIL = 'auto@status.im'
27    }
28  
29    stages {
30      stage('Install') {
31        steps {
32          script {
33            nix.develop('yarn install')
34          }
35        }
36      }
37  
38      stage('Build') {
39        steps {
40          script {
41            nix.develop('yarn build')
42            jenkins.genBuildMetaJSON('build/build.json')
43          }
44        }
45      }
46  
47      stage('Publish') {
48        steps {
49          sshagent(credentials: ['status-im-auto-ssh']) {
50            script {
51              nix.develop("""
52                ghp-import \
53                  -b ${deployBranch()} \
54                  -c ${deployDomain()} \
55                  -p build
56                """, pure: false)
57              }
58           }
59        }
60      }
61    }
62  
63    post {
64      cleanup { cleanWs() }
65    }
66  }
67  
68  def isMasterBranch() { GIT_BRANCH ==~ /.*master/ }
69  def deployBranch() { isMasterBranch() ? 'deploy-master' : 'deploy-develop' }
70  def deployDomain() { isMasterBranch() ? 'codex.storage' : 'dev.codex.storage' }