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
On Wed, Aug 29, 2018 at 12:59 AM Gabe Nydick <[email protected]> wrote:
> 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"
> }
> }
> }
> }
>
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CACTWNKBkGhor-cLVO_oFNCN8hp-X7r%2BiK6dDcJowvGTyAsOLkw%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CACTWNKBkGhor-cLVO_oFNCN8hp-X7r%2BiK6dDcJowvGTyAsOLkw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6NyexPrjDeT_%3DszNHVF6391uDNdqsb3N04V5BEKS%3D4%2BEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.