Update Jenkinsfile
- Rewrite as declarative - Add credentials - Gate images pushes to master branch only Signed-off-by: Dave Tucker <dt@docker.com>
This commit is contained in:
parent
b832e37864
commit
0355778d6e
79
Jenkinsfile
vendored
79
Jenkinsfile
vendored
@ -1,31 +1,54 @@
|
|||||||
node {
|
pipeline {
|
||||||
def resultImage
|
agent {
|
||||||
def voteImage
|
node {
|
||||||
def workerImage
|
label 'ubuntu-1604-aufs-stable'
|
||||||
docker.withRegistry("https://index.docker.io/v1/", "dockersamples" ) {
|
}
|
||||||
stage('Clone repo') {
|
}
|
||||||
checkout scm
|
stages {
|
||||||
|
stage('Build result') {
|
||||||
|
steps {
|
||||||
|
sh 'docker build -t dockersamples/result ./result'
|
||||||
}
|
}
|
||||||
stage('Build result') {
|
}
|
||||||
resultImage = docker.build("dockersamples/result", "./result")
|
stage('Build vote') {
|
||||||
}
|
steps {
|
||||||
stage('Build vote') {
|
sh 'docker build -t dockersamples/vote ./vote'
|
||||||
voteImage = docker.build("dockersamples/vote", "./vote")
|
|
||||||
}
|
|
||||||
stage('Build worker dotnet') {
|
|
||||||
workerImage = docker.build("dockersamples/worker", "./worker")
|
|
||||||
}
|
|
||||||
stage('Push result image') {
|
|
||||||
resultImage.push("${env.BUILD_NUMBER}")
|
|
||||||
resultImage.push()
|
|
||||||
}
|
|
||||||
stage('Push vote image') {
|
|
||||||
voteImage.push("${env.BUILD_NUMBER}")
|
|
||||||
voteImage.push()
|
|
||||||
}
|
|
||||||
stage('Push worker image') {
|
|
||||||
workerImage.push("${env.BUILD_NUMBER}")
|
|
||||||
workerImage.push()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
stage('Build worker') {
|
||||||
|
steps {
|
||||||
|
sh 'docker build -t dockersamples/worker ./worker'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Push result image') {
|
||||||
|
when {
|
||||||
|
branch 'master'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
withDockerRegistry(credentialsId: 'dockerbuildbot-index.docker.io', url:'') {
|
||||||
|
sh 'docker push dockersamples/result'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Push vote image') {
|
||||||
|
when {
|
||||||
|
branch 'master'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
withDockerRegistry(credentialsId: 'dockerbuildbot-index.docker.io', url:'') {
|
||||||
|
sh 'docker push dockersamples/vote'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Push worker image') {
|
||||||
|
when {
|
||||||
|
branch 'master'
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
withDockerRegistry(credentialsId: 'dockerbuildbot-index.docker.io', url:'') {
|
||||||
|
sh 'docker push dockersamples/worker'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user