/ Jenkinsfile
Jenkinsfile
 1  pipeline {
 2    agent { label 'linux' }
 3  
 4    options {
 5      disableConcurrentBuilds()
 6      /* manage how many builds we keep */
 7      buildDiscarder(logRotator(
 8        numToKeepStr: '20',
 9        daysToKeepStr: '30',
10      ))
11    }
12  
13    environment {
14      GIT_USER = 'status-im-auto'
15      GIT_MAIL = 'auto@status.im'
16      /* Dev site deployment. */
17      DEV_SITE = 'dev-ambassador.status.im'
18      DEV_HOST = 'jenkins@node-01.do-ams3.sites.misc.statusim.net'
19      SCP_OPTS = 'StrictHostKeyChecking=no'
20    }
21  
22    stages {
23      stage('Git Prep') {
24        steps {
25          sh "git config user.name ${GIT_USER}"
26          sh "git config user.email ${GIT_MAIL}"
27        }
28      }
29  
30      stage('Install Deps') {
31        steps {
32          sh 'yarn install'
33        }
34      }
35  
36      stage('Build') {
37        steps {
38          sh 'yarn run clean'
39          sh 'yarn run build'
40        }
41      }
42  
43      stage('Robot') {
44        when { expression { !GIT_BRANCH.endsWith('master') } }
45        steps { script {
46          sh 'echo "Disallow: /" >> build/robots.txt'
47        } }
48      }
49  
50      stage('Publish Prod') {
51        when { expression { GIT_BRANCH.endsWith('master') } }
52        steps { script {
53          sshagent(credentials: ['status-im-auto-ssh']) {
54            sh 'yarn run deploy'
55          }
56        } }
57      }
58  
59      stage('Publish Devel') {
60        when { expression { !GIT_BRANCH.endsWith('master') } }
61        steps { script {
62          sshagent(credentials: ['jenkins-ssh']) {
63            sh """
64              rsync -e 'ssh -o ${SCP_OPTS}' -r --delete build/. \
65              ${env.DEV_HOST}:/var/www/${env.DEV_SITE}/
66            """
67          }
68        } }
69      }
70    }
71  }