Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active July 16, 2018 19:32
Show Gist options
  • Save vfarcic/f990482b94e1c292d36da4526a4fa536 to your computer and use it in GitHub Desktop.
Save vfarcic/f990482b94e1c292d36da4526a4fa536 to your computer and use it in GitHub Desktop.
import java.text.SimpleDateFormat
currentBuild.displayName = new SimpleDateFormat("yy.MM.dd").format(new Date()) + "-" + env.BUILD_NUMBER
env.REPO = "https://github.com/vfarcic/go-demo-3.git"
env.IMAGE = "vfarcic/go-demo-3"
env.TAG_BETA = "${currentBuild.displayName}-${env.BRANCH_NAME}"
node("docker") {
stage("build") {
git "${env.REPO}"
sh """sudo docker image build \
-t ${env.IMAGE}:${env.TAG_BETA} ."""
withCredentials([usernamePassword(
credentialsId: "docker",
usernameVariable: "USER",
passwordVariable: "PASS"
)]) {
sh """sudo docker login \
-u $USER -p $PASS"""
}
sh """sudo docker image push \
${env.IMAGE}:${env.TAG_BETA}"""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment