From 8a15f69cb679a365802ed3cf0ce0d9882706ec18 Mon Sep 17 00:00:00 2001 From: swb Date: Thu, 1 Jun 2023 23:01:37 +0100 Subject: [PATCH] add jenkinsfile --- Jenkinsfile | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..479df60 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,61 @@ +pipeline { + agent { label 'linux' } + + options { + disableConcurrentBuilds() + /* manage how many builds we keep */ + buildDiscarder(logRotator( + numToKeepStr: '20', + daysToKeepStr: '30', + )) + } + + environment { + GIT_COMMITTER_NAME = 'status-im-auto' + GIT_COMMITTER_EMAIL = 'auto@status.im' + PROD_SITE = 'nimbus.team' + DEV_SITE = 'dev.nimbus.team' + DEV_HOST = 'jenkins@node-01.do-ams3.sites.misc.statusim.net' + SCP_OPTS = 'StrictHostKeyChecking=no' + } + + stages { + stage('Install') { + steps { + sh "yarn install" + } + } + + stage('Build') { + steps { + sh 'yarn build' + sh "echo ${env.PROD_SITE} > build/CNAME" + } + } + + stage('Publish Prod') { + when { expression { env.GIT_BRANCH ==~ /.*master/ } } + steps { + 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 """ + rsync -e 'ssh -o ${SCP_OPTS}' -r --delete build/. \ + ${env.DEV_HOST}:/var/www/${env.DEV_SITE}/ + """ + } + } + } + } + + post { + cleanup { cleanWs() } + } +}