feat: use two deploy branches for CI builds

This commit is contained in:
Siddarth Kumar 2024-05-31 18:30:16 +05:30 committed by Jakub Sokołowski
parent 80c7cb5686
commit 3e2a765d05
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 18 additions and 21 deletions

39
Jenkinsfile vendored
View File

@ -1,3 +1,6 @@
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.8'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }
@ -13,44 +16,34 @@ pipeline {
environment { environment {
GIT_COMMITTER_NAME = 'status-im-auto' GIT_COMMITTER_NAME = 'status-im-auto'
GIT_COMMITTER_EMAIL = 'auto@status.im' GIT_COMMITTER_EMAIL = 'auto@status.im'
PROD_SITE = 'afaik.institute'
DEV_SITE = 'dev.afaik.institute'
DEV_HOST = 'jenkins@node-01.do-ams3.sites.misc.statusim.net'
SCP_OPTS = 'StrictHostKeyChecking=no'
} }
stages { stages {
stage('Install') { stage('Install') {
steps { steps {
sh "yarn install" sh 'yarn install'
} }
} }
stage('Build') { stage('Build') {
steps { steps {
sh 'yarn build' script {
sh "echo ${env.PROD_SITE} > build/CNAME" sh 'yarn build'
jenkins.genBuildMetaJSON('build/build.json')
}
} }
} }
stage('Publish Prod') { stage('Publish') {
when { expression { env.GIT_BRANCH ==~ /.*master/ } }
steps { steps {
sshagent(credentials: ['status-im-auto-ssh']) { sshagent(credentials: ['status-im-auto-ssh']) {
sh "ghp-import -p build"
}
}
}
stage('Publish Devel') {
when { expression { env.GIT_BRANCH ==~ /.*develop/ } }
steps {
sshagent(credentials: ['jenkins-ssh']) {
sh """ sh """
rsync -e 'ssh -o ${SCP_OPTS}' -r --delete build/. \ ghp-import \
${env.DEV_HOST}:/var/www/${env.DEV_SITE}/ -b ${deployBranch()} \
-c ${deployDomain()} \
-p build
""" """
} }
} }
} }
} }
@ -59,3 +52,7 @@ pipeline {
cleanup { cleanWs() } cleanup { cleanWs() }
} }
} }
def isMasterBranch() { GIT_BRANCH ==~ /.*master/ }
def deployBranch() { isMasterBranch() ? 'deploy-master' : 'deploy-develop' }
def deployDomain() { isMasterBranch() ? 'afaik.institute' : 'dev.afaik.institute' }