This commit is contained in:
Jamie Curnow 2018-07-30 16:47:28 +10:00
parent f5446cbe40
commit 9fbfb1648b

96
Jenkinsfile vendored
View File

@ -17,67 +17,65 @@ pipeline {
sh 'docker pull $DOCKER_CI_TOOLS' sh 'docker pull $DOCKER_CI_TOOLS'
} }
} }
stages { stage('Build') {
stage('Build') { parallel {
parallel { stage('x86_64') {
stage('x86_64') { steps {
steps { ansiColor('xterm') {
ansiColor('xterm') { // Codebase
// Codebase sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest yarn --registry=$NPM_REGISTRY install'
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest yarn --registry=$NPM_REGISTRY install' sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest npm runscript build'
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest npm runscript build' sh 'rm -rf node_modules'
sh 'rm -rf node_modules' sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest yarn --registry=$NPM_REGISTRY install --prod'
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:latest yarn --registry=$NPM_REGISTRY install --prod' sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune'
sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune'
// Docker Build // Docker Build
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .' sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .'
// Private Registry // Private Registry
sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION' sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION'
sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION' sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION'
// Dockerhub // Dockerhub
sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION'
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
sh "docker login -u '${duser}' -p '$dpass'" sh "docker login -u '${duser}' -p '$dpass'"
sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION'
}
sh 'docker rmi $TEMP_IMAGE_NAME'
} }
sh 'docker rmi $TEMP_IMAGE_NAME'
} }
} }
stage('armhf') { }
agent { stage('armhf') {
label 'armhf' agent {
} label 'armhf'
steps { }
ansiColor('xterm') { steps {
// Codebase ansiColor('xterm') {
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install' // Codebase
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf npm runscript build' sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install'
sh 'rm -rf node_modules' sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf npm runscript build'
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install --prod' sh 'rm -rf node_modules'
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app $IMAGE_NAME-base:armhf yarn --registry=$NPM_REGISTRY install --prod'
// Docker Build // Docker Build
sh 'docker build --pull --no-cache --squash --compress -t TEMP_IMAGE_NAME_ARM .' sh 'docker build --pull --no-cache --squash --compress -t TEMP_IMAGE_NAME_ARM .'
// Private Registry // Private Registry
sh 'docker tag TEMP_IMAGE_NAME_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf' sh 'docker tag TEMP_IMAGE_NAME_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf'
sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf' sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf'
// Dockerhub // Dockerhub
sh 'docker tag TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf' sh 'docker tag TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf'
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
sh "docker login -u '${duser}' -p '$dpass'" sh "docker login -u '${duser}' -p '$dpass'"
sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf' sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf'
}
sh 'docker rmi TEMP_IMAGE_NAME_ARM'
} }
sh 'docker rmi TEMP_IMAGE_NAME_ARM'
} }
} }
} }