Created
August 24, 2017 09:32
-
-
Save ntakouris/a296d626c20cbf3879db684b4a393cc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage('BitBucket Publish'){ | |
//Find out commit hash | |
sh 'git rev-parse HEAD > commit' | |
def commit = readFile('commit').trim() | |
//Find out current branch | |
sh 'git name-rev --name-only HEAD > GIT_BRANCH' | |
def branch = readFile('GIT_BRANCH').trim() | |
//strip off repo-name/origin/ (optional) | |
branch = branch.substring(branch.lastIndexOf('/') + 1) | |
def archive = "${GOPATH}/project-${branch}-${commit}.tar.gz" | |
echo "Building Archive ${archive}" | |
sh """tar -cvzf ${archive} $GOPATH/src/cmd/project/project""" | |
echo "Uploading ${archive} to BitBucket Downloads" | |
withCredentials([string(credentialsId: 'bb-upload-key', variable: 'KEY')]) { | |
sh """curl -s -u 'user:${KEY}' -X POST 'Downloads Page URL' --form files=@'${archive}' --fail""" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment