Fix jenkins (#139)

* Attempt to fix Jenkinsfile

* Only deploy on master
This commit is contained in:
Matt Robinson 2018-07-13 11:02:33 -04:00 committed by Philip Hutchins
parent ff4e63b74f
commit 544cf46b10
2 changed files with 27 additions and 32 deletions

52
Jenkinsfile vendored
View File

@ -1,40 +1,23 @@
node('node') { node('node') {
// Install the desired Go version
def root = tool name: 'Go 1.10', type: 'go'
// Export environment variables pointing to the directory where Go was installed
withEnv(["GOROOT=${root}", "PATH+GO=${root}/bin", "PATH=$PATH:${root}/bin"]) {
sh 'go version'
}
try { try {
stage 'Checkout' stage('Checkout') {
checkout scm
}
checkout scm stage('Build Images') {
sh 'make images'
}
stage 'Test' stage('Deploy') {
if (env.BRANCH_NAME != 'master') {
sh """#!/bin/bash -e echo 'Skipping deploy stage'
echo $root return
echo "path=" }
echo $PATH sh 'make push-images'
make build-dev-deps lint }
"""
stage 'Build Docker'
echo 'Build'
stage 'Deploy'
echo 'Deploy'
stage 'Cleanup'
echo 'prune and cleanup'
} }
catch (err) { catch (err) {
currentBuild.result = "FAILURE" currentBuild.result = "FAILURE"
@ -47,5 +30,14 @@ node('node') {
throw err throw err
*/ */
}
finally {
stage('Cleanup') {
sh 'make clean-images'
deleteDir()
}
} }
} }

View File

@ -79,12 +79,15 @@ clean-local:
images: images:
docker build --build-arg VERSION=${GO_VERSION} -t storjlabs/overlay:${TAG}-${GO_VERSION} -f cmd/overlay/Dockerfile . docker build --build-arg VERSION=${GO_VERSION} -t storjlabs/overlay:${TAG}-${GO_VERSION} -f cmd/overlay/Dockerfile .
docker tag storjlabs/overlay:${TAG}-${GO_VERSION} overlay:latest docker tag storjlabs/overlay:${TAG}-${GO_VERSION} storjlabs/overlay:latest
push-images: push-images:
docker push storjlabs/overlay:${TAG}-${GO_VERSION} docker push storjlabs/overlay:${TAG}-${GO_VERSION}
docker push storjlabs/overlay:latest docker push storjlabs/overlay:latest
clean-images:
-docker rmi storjlabs/overlay:${TAG}-${GO_VERSION} storjlabs/overlay:latest
install-deps: install-deps:
go get -u -v golang.org/x/vgo go get -u -v golang.org/x/vgo
cd vgo install ./... cd vgo install ./...