multibranch pipeline not handling multiple scripts

17 views
Skip to first unread message

Gabe Nydick

unread,
Aug 29, 2018, 3:30:17 PM8/29/18
to jenkins...@googlegroups.com
Here is my Jenkinsfile, minus the variable declarations...


podTemplate(label: label, containers: [
containerTemplate(name: 'kubectl', image: "$registry/kubectl:latest", command: 'cat', ttyEnabled: true),
containerTemplate(name: 'helm', image: "$registry/helm:latest", 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('jnlp') { // inheriteed container

checkout scm
def dockerImage = "$image:${gitCommit}"
def dockerLatest = "$image:latest"
def dockerfile = 'base.Dockerfile'


docker.withRegistry("", "$credentials") {
docker.build(dockerImage, "-f ${dockerfile} .")
docker.build(dockerLatest, "-f ${dockerfile} .")
docker.image(dockerImage).push()
docker.image(dockerLatest).push()
}
}
}

stage('Run kubectl') {
container('kubectl') {
sh """
kubectl get pods
"""
}
}
stage('Run helm') {
container('helm') {
sh """
helm list
"""
}
}
}

}

I get the below error whenever the second stage starts. It's as if the stages are sharing their contents as any scripts i put in the first stage, appear in the other containers (all three, including the default jnlp container). As soon as stage 1 completes, those contents are wiped, and it throws this error.

What am I doing wrong?


[h_ci-cd_dev_2018-08-13-kube-B25Q2OMNNSNLLVD3BXC7FMQBF3IKQYJE4OSTUSVSM65SZ6NCGBAQ] Running shell script

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

script returned exit code 127
Reply all
Reply to author
Forward
0 new messages