From f0092bc85a3b3b09ddb63270978c775bb6563c30 Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 15 Sep 2017 15:20:03 +0200 Subject: [PATCH 1/3] Push master branch to public repo after successful build Note that this has to happen outside of the docker container to work around issues with git and user ids, so we've had to modify the pipeline to explicitly run the steps inside docker as needed. --- services/web/Jenkinsfile | 58 +++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index 8a844ca0a0..82dd2c049c 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -1,11 +1,6 @@ pipeline { - agent { - docker { - image 'node:6.9.5' - args "-v /var/lib/jenkins/.npm:/tmp/.npm" - } - } + agent any environment { HOME = "/tmp" @@ -18,6 +13,12 @@ pipeline { stages { stage('Set up') { + agent { + docker { + image 'node:6.9.5' + reuseNode true + } + } steps { // we need to disable logallrefupdates, else git clones during the npm install will require git to lookup the user id // which does not exist in the container's /etc/passwd file, causing the clone to fail. @@ -44,7 +45,15 @@ pipeline { } stage('Install') { + agent { + docker { + image 'node:6.9.5' + args "-v /var/lib/jenkins/.npm:/tmp/.npm" + reuseNode true + } + } steps { + sh 'git config --global core.logallrefupdates false' sh 'mv app/views/external/robots.txt public/robots.txt' sh 'mv app/views/external/googlebdb0f8f7f4a17241.html public/googlebdb0f8f7f4a17241.html' sh 'npm install' @@ -56,24 +65,48 @@ pipeline { } stage('Compile') { + agent { + docker { + image 'node:6.9.5' + reuseNode true + } + } steps { sh 'node_modules/.bin/grunt compile --verbose' } } stage('Smoke Test') { + agent { + docker { + image 'node:6.9.5' + reuseNode true + } + } steps { sh 'node_modules/.bin/grunt compile:smoke_tests' } } stage('Minify') { + agent { + docker { + image 'node:6.9.5' + reuseNode true + } + } steps { sh 'node_modules/.bin/grunt compile:minify' } } stage('Unit Test') { + agent { + docker { + image 'node:6.9.5' + reuseNode true + } + } steps { sh 'env NODE_ENV=development ./node_modules/.bin/grunt test:unit --reporter=tap' } @@ -87,6 +120,7 @@ pipeline { sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .' } } + stage('Publish') { steps { withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") { @@ -96,6 +130,18 @@ pipeline { } } } + + + stage('Sync OSS') { + when { + branch 'master' + } + steps { + sshagent (credentials: ['GIT_DEPLOY_KEY']) { + sh 'git push git@github.com:sharelatex/web-sharelatex.git HEAD:ja-oss-test' + } + } + } } post { From a0ac11eb0dc6dce84812fb961255a67da28bbbf8 Mon Sep 17 00:00:00 2001 From: James Allen Date: Mon, 18 Sep 2017 11:11:33 +0200 Subject: [PATCH 2/3] Actually push to master branch --- services/web/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index 82dd2c049c..8e3f2af972 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -138,7 +138,7 @@ pipeline { } steps { sshagent (credentials: ['GIT_DEPLOY_KEY']) { - sh 'git push git@github.com:sharelatex/web-sharelatex.git HEAD:ja-oss-test' + sh 'git push git@github.com:sharelatex/web-sharelatex.git HEAD:master' } } } From d0ce22b0f85ec1931c4454a866dd6dd7e0116dd0 Mon Sep 17 00:00:00 2001 From: James Allen Date: Mon, 18 Sep 2017 11:30:43 +0200 Subject: [PATCH 3/3] Add in overleaf-integration module to build --- services/web/Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index 8e3f2af972..c43f82ac4e 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -41,6 +41,7 @@ pipeline { checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/learn-wiki'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@bitbucket.org:sharelatex/learn-wiki-web-module.git']]]) checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/templates'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/templates-webmodule.git']]]) checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/track-changes'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/track-changes-web-module.git']]]) + checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/overleaf-integration'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/overleaf-integration-web-module.git']]]) } }