2017-11-08 13:40:20 +00:00
|
|
|
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
|
|
|
|
|
2017-08-16 09:43:48 +00:00
|
|
|
pipeline {
|
|
|
|
|
2017-09-15 13:20:03 +00:00
|
|
|
agent any
|
2017-08-16 09:43:48 +00:00
|
|
|
|
|
|
|
environment {
|
|
|
|
HOME = "/tmp"
|
|
|
|
}
|
|
|
|
|
|
|
|
triggers {
|
|
|
|
pollSCM('* * * * *')
|
2017-11-08 13:40:20 +00:00
|
|
|
cron(cron_string)
|
2017-08-16 09:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Set up') {
|
2017-09-15 13:20:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 09:43:48 +00:00
|
|
|
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.
|
|
|
|
sh 'git config --global core.logallrefupdates false'
|
|
|
|
|
|
|
|
sh 'rm -rf node_modules/*'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Clone Dependencies') {
|
|
|
|
steps {
|
|
|
|
sh 'rm -rf public/brand modules'
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'public/brand'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/brand-sharelatex']]])
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'app/views/external'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/external-pages-sharelatex']]])
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/web-sharelatex-modules']]])
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/admin-panel'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/admin-panel']]])
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/groovehq'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@bitbucket.org:sharelatex/groovehq']]])
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/references-search'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@bitbucket.org:sharelatex/references-search.git']]])
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/tpr-webmodule'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/tpr-webmodule.git ']]])
|
|
|
|
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']]])
|
2017-11-06 10:47:24 +00:00
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/sk-unlisted-projects']], 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']]])
|
2017-09-18 09:30:43 +00:00
|
|
|
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']]])
|
2017-10-04 13:57:08 +00:00
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/overleaf-account-merge'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/overleaf-account-merge.git']]])
|
2017-08-16 09:43:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Install') {
|
2017-09-15 13:20:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
args "-v /var/lib/jenkins/.npm:/tmp/.npm"
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 09:43:48 +00:00
|
|
|
steps {
|
2017-09-15 13:20:03 +00:00
|
|
|
sh 'git config --global core.logallrefupdates false'
|
2017-08-16 09:43:48 +00:00
|
|
|
sh 'mv app/views/external/robots.txt public/robots.txt'
|
|
|
|
sh 'mv app/views/external/googlebdb0f8f7f4a17241.html public/googlebdb0f8f7f4a17241.html'
|
|
|
|
sh 'npm install'
|
|
|
|
sh 'npm rebuild'
|
2017-10-09 13:23:05 +00:00
|
|
|
// It's too easy to end up shrinkwrapping to an outdated version of translations.
|
2017-10-09 13:22:04 +00:00
|
|
|
// Ensure translations are always latest, regardless of shrinkwrap
|
|
|
|
sh 'npm install git+https://github.com/sharelatex/translations-sharelatex.git#master'
|
2017-08-16 09:43:48 +00:00
|
|
|
sh 'npm install --quiet grunt'
|
|
|
|
sh 'npm install --quiet grunt-cli'
|
|
|
|
sh 'ls -l node_modules/.bin'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Compile') {
|
2017-09-15 13:20:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 09:43:48 +00:00
|
|
|
steps {
|
|
|
|
sh 'node_modules/.bin/grunt compile --verbose'
|
2017-09-29 09:37:39 +00:00
|
|
|
// replace the build number placeholder for sentry
|
|
|
|
sh 'node_modules/.bin/grunt version'
|
2017-08-16 09:43:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Smoke Test') {
|
2017-09-15 13:20:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 09:43:48 +00:00
|
|
|
steps {
|
|
|
|
sh 'node_modules/.bin/grunt compile:smoke_tests'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Minify') {
|
2017-09-15 13:20:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 09:43:48 +00:00
|
|
|
steps {
|
|
|
|
sh 'node_modules/.bin/grunt compile:minify'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Unit Test') {
|
2017-09-15 13:20:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'node:6.9.5'
|
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 09:43:48 +00:00
|
|
|
steps {
|
|
|
|
sh 'env NODE_ENV=development ./node_modules/.bin/grunt test:unit --reporter=tap'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-27 08:37:20 +00:00
|
|
|
stage('Acceptance Tests') {
|
|
|
|
steps {
|
2017-09-27 08:50:34 +00:00
|
|
|
sh 'docker pull sharelatex/acceptance-test-runner'
|
|
|
|
sh 'docker run --rm -v $(pwd):/app --env SHARELATEX_ALLOW_PUBLIC_ACCESS=true sharelatex/acceptance-test-runner'
|
2017-09-27 08:37:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-16 09:43:48 +00:00
|
|
|
stage('Package') {
|
|
|
|
steps {
|
|
|
|
sh 'rm -rf ./node_modules/grunt*'
|
2017-09-04 13:58:13 +00:00
|
|
|
sh 'echo ${BUILD_NUMBER} > build_number.txt'
|
2017-08-16 09:43:48 +00:00
|
|
|
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
|
|
|
|
sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
|
|
|
|
}
|
|
|
|
}
|
2017-09-15 13:20:03 +00:00
|
|
|
|
2017-08-16 09:43:48 +00:00
|
|
|
stage('Publish') {
|
|
|
|
steps {
|
|
|
|
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
|
|
|
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
|
2017-09-04 13:58:13 +00:00
|
|
|
// The deployment process uses this file to figure out the latest build
|
|
|
|
s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
|
2017-08-16 09:43:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-15 13:20:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
stage('Sync OSS') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sshagent (credentials: ['GIT_DEPLOY_KEY']) {
|
2017-09-18 09:11:33 +00:00
|
|
|
sh 'git push git@github.com:sharelatex/web-sharelatex.git HEAD:master'
|
2017-09-15 13:20:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-16 09:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
failure {
|
|
|
|
mail(from: "${EMAIL_ALERT_FROM}",
|
|
|
|
to: "${EMAIL_ALERT_TO}",
|
|
|
|
subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
|
|
|
|
body: "Build: ${BUILD_URL}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The options directive is for configuration that applies to the whole job.
|
|
|
|
options {
|
2017-09-04 15:02:16 +00:00
|
|
|
// Only build one at a time
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
|
2017-08-16 09:43:48 +00:00
|
|
|
// we'd like to make sure remove old builds, so we don't fill up our storage!
|
|
|
|
buildDiscarder(logRotator(numToKeepStr:'50'))
|
|
|
|
|
|
|
|
// And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
|
|
|
|
timeout(time: 30, unit: 'MINUTES')
|
|
|
|
}
|
|
|
|
}
|