Last active
July 16, 2018 19:32
-
-
Save vfarcic/f990482b94e1c292d36da4526a4fa536 to your computer and use it in GitHub Desktop.
This file contains 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
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