2017-09-08 09:06:04 -04:00
|
|
|
pipeline {
|
|
|
|
|
|
|
|
agent any
|
|
|
|
|
|
|
|
triggers {
|
|
|
|
pollSCM('* * * * *')
|
|
|
|
cron('@daily')
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Clean') {
|
|
|
|
steps {
|
|
|
|
// This is a terrible hack to set the file ownership to jenkins:jenkins so we can cleanup the directory
|
|
|
|
sh 'docker run -v $(pwd):/app --rm busybox /bin/chown -R 111:119 /app'
|
2017-09-28 06:50:33 -04:00
|
|
|
sh 'rm -fr node_modules'
|
2017-09-08 09:06:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Install') {
|
|
|
|
agent {
|
|
|
|
docker {
|
2017-09-28 06:50:33 -04:00
|
|
|
image 'node:6.11.2'
|
2017-09-28 06:51:41 -04:00
|
|
|
args "-v /var/lib/jenkins/.npm:/tmp/.npm -e HOME=/tmp"
|
2017-09-08 09:06:04 -04:00
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh 'git config --global core.logallrefupdates false'
|
|
|
|
sh 'rm -fr node_modules'
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: '_docker-runner'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/docker-runner-sharelatex']]])
|
|
|
|
sh 'npm install ./_docker-runner'
|
2017-09-28 06:50:33 -04:00
|
|
|
sh 'rm -fr ./_docker-runner ./_docker-runner@tmp'
|
2017-09-08 09:06:04 -04:00
|
|
|
sh 'npm install'
|
2017-09-28 08:46:01 -04:00
|
|
|
sh 'npm rebuild'
|
2017-09-26 06:44:48 -04:00
|
|
|
sh 'npm install --quiet grunt-cli'
|
2017-09-08 09:06:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Compile and Test') {
|
|
|
|
agent {
|
|
|
|
docker {
|
2017-09-28 06:50:33 -04:00
|
|
|
image 'node:6.11.2'
|
2017-09-08 09:06:04 -04:00
|
|
|
reuseNode true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh 'node_modules/.bin/grunt compile:app'
|
|
|
|
sh 'node_modules/.bin/grunt compile:acceptance_tests'
|
|
|
|
sh 'NODE_ENV=development node_modules/.bin/grunt test:unit'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Acceptance Tests') {
|
|
|
|
environment {
|
|
|
|
TEXLIVE_IMAGE="quay.io/sharelatex/texlive-full:2017.1"
|
|
|
|
}
|
|
|
|
steps {
|
2017-09-28 06:50:33 -04:00
|
|
|
sh 'mkdir -p compiles cache'
|
2017-09-08 09:06:04 -04:00
|
|
|
// Not yet running, due to volumes/sibling containers
|
|
|
|
sh 'docker container prune -f'
|
|
|
|
sh 'docker pull $TEXLIVE_IMAGE'
|
2017-09-28 06:50:33 -04:00
|
|
|
sh 'docker pull sharelatex/acceptance-test-runner:clsi-6.11.2'
|
|
|
|
sh 'docker run --rm -e SIBLING_CONTAINER_USER=root -e SANDBOXED_COMPILES_HOST_DIR=$(pwd)/compiles -e SANDBOXED_COMPILES_SIBLING_CONTAINERS=true -e TEXLIVE_IMAGE=$TEXLIVE_IMAGE -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/app sharelatex/acceptance-test-runner:clsi-6.11.2'
|
|
|
|
// This is a terrible hack to set the file ownership to jenkins:jenkins so we can cleanup the directory
|
|
|
|
sh 'docker run -v $(pwd):/app --rm busybox /bin/chown -R 111:119 /app'
|
|
|
|
sh 'rm -r compiles cache server.log db.sqlite config/settings.defaults.coffee'
|
2017-09-08 09:06:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Package') {
|
|
|
|
steps {
|
|
|
|
sh 'echo ${BUILD_NUMBER} > build_number.txt'
|
|
|
|
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 .'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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")
|
|
|
|
// 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")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
// 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')
|
|
|
|
}
|
|
|
|
}
|