multi-branch pipeline / kubernetes stage probem

40 weergaven
Naar het eerste ongelezen bericht

Gabe Nydick

ongelezen,
28 aug 2018, 18:59:3328-08-2018
aan jenkins...@googlegroups.com
My Jenkinsfile is below...

There are 3 containers defined, each with their appropriate docker image. There are 3 stages defined, each one exclusively uses one of the containers.

While exec'd into all of the containers, each one of them have a

workspace/<long name>@/durable-<short name>/script.sh

the contents of that script in all three containers is the script from the stage called 'Create Docker Images'.

When that stage completes, jenkins moves on to the next stage, but then the durable-<short name> directory is gone. I then get the following error, which makes sense.

sh: /home/jenkins/workspace/h_ci-cd_dev_2018-08-13-kube-B25Q2OMNNSNLLVD3BXC7FMQBF3IKQYJE4OSTUSVSM65SZ6NCGBAQ@tmp/durable-170e31a9/script.sh: not found


Did I author the Jenkinsfile incorrectly or is this a bug in the pipeline?



def label = "jenkins-builder-${UUID.randomUUID().toString()}"

podTemplate(label: label, inheritFrom: 'jenkins-builder', containers: [
containerTemplate(name: 'kubectl', image: '<redact>', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'helm', image: '<redact>', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'jnlp', image: '<redact>', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
]) {
node(label) {
def myRepo = checkout scm
def gitCommit = myRepo.GIT_COMMIT
def gitBranch = myRepo.GIT_BRANCH
def shortGitCommit = "${gitCommit[0..10]}"
def previousGitCommit = sh(script: "git rev-parse ${gitCommit}~", returnStdout: true)

stage('Create Docker images') {
container('jenkins-agent') {
sh """
\$(aws ecr get-login --no-include-email --region=us-west-2 | sed 's/-e none//')
docker build -t <redact>:${gitCommit} . -f base.Dockerfile
docker push <redact>:${gitCommit}
"""
}
}
stage('Run kubectl') {
container('kubectl') {
sh "kubectl get pods"
}
}
stage('Run helm') {
container('helm') {
sh "helm list"
}
}
}
}


Carlos Sanchez

ongelezen,
29 aug 2018, 03:37:1329-08-2018
aan Jenkins Users
Your example wouldn't even work, the jnlp container definition is wrong, can't use cat there

containerTemplate(name: 'jnlp', image: '<redact>', command: 'cat', ttyEnabled: true)

and then you try to use container('jenkins-agent') which is not defined


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CACTWNKBkGhor-cLVO_oFNCN8hp-X7r%2BiK6dDcJowvGTyAsOLkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Gabe Nydick

ongelezen,
29 aug 2018, 11:20:2429-08-2018
aan jenkins...@googlegroups.com
ha! good catch.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6NyexPrjDeT_%3DszNHVF6391uDNdqsb3N04V5BEKS%3D4%2BEg%40mail.gmail.com.

Gabe Nydick

ongelezen,
29 aug 2018, 12:41:2429-08-2018
aan jenkins...@googlegroups.com
What was wrong about using 'cat' there? is it just the wrong health check?

Carlos Sanchez

ongelezen,
29 aug 2018, 12:47:3129-08-2018
aan Jenkins Users
the jnlp container needs to execute the jenkins agent, not cat

ha! good catch.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CACTWNKBHYPGgcaKzJGhB2m3KdPxF3asvf44kvZVBZ0p4%2B%2BgLLA%40mail.gmail.com.

Gabe Nydick

ongelezen,
29 aug 2018, 12:48:2229-08-2018
aan jenkins...@googlegroups.com
Also, I had already fixed the Jenkinsfile, but the problem still persists.

Gabe Nydick

ongelezen,
29 aug 2018, 12:49:3829-08-2018
aan jenkins...@googlegroups.com
Right, I fixed that.

ha! good catch.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6MoAoggD3c2G6gg%3DK%2BUVynbKTrCrMDzVmV-PCw1RM_NOw%40mail.gmail.com.
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten