Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-53056

Can only execute actions on jnlp container with Kubernetes multi container template

XMLWordPrintable

      I'm running Jenkins 2.121.2 with the Kubernetes plugin 1.12.3.

      I want to create a pod with multiple containers. Each container should be used for different tasks in the pipeline. The kubernetes-plugin github has an example of this which I have been testing: https://github.com/jenkinsci/kubernetes-plugin/blob/master/examples/declarative-multiple-containers.groovy

       

      I've created my own jnlp docker container based on the jenkins-slave container which I am declaring manually rather than having Jenkins spin one up for me. The following is my pipeline code:

      pipeline { 
        agent { label 'test' }
      
        stages {
          stage('Run maven') {
            steps {
              container('maven') {
                sh 'mvn -version'
              }
              container('busybox') {
                sh '/bin/busybox'
              }
            }
          }
        }
      }
      

      The result that I get from from executing my pipeline is as follows:

      Started by user <<REDACTED>>
      Obtained Jenkinsfile from git <<REDACTED>>
      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] node
      Still waiting to schedule task
      Waiting for next available executor
      Agent test-tqc37 is provisioned from template Kubernetes Pod Template
      Agent specification [Kubernetes Pod Template] (test): 
      
      Running on test-tqc37 in /home/jenkins/workspace/ZZ - Test/<<REDACTED>>
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Declarative: Checkout SCM)
      [Pipeline] checkout
      Cloning the remote Git repository
      Cloning repository <<REDACTED>>
       > git init /home/jenkins/workspace/ZZ - Test/<<REDACTED>> # timeout=10
      Fetching upstream changes from <<REDACTED>>
       > git --version # timeout=10
      using GIT_ASKPASS to set credentials <<REDACTED>>
       > git fetch --tags --progress <<REDACTED>> +refs/heads/*:refs/remotes/origin/*
       > git config remote.origin.url <<REDACTED>> # timeout=10
       > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git config remote.origin.url <<REDACTED>> # timeout=10
      Fetching upstream changes from <<REDACTED>>
      using GIT_ASKPASS to set credentials <<REDACTED>>
       > git fetch --tags --progress <<REDACTED>> +refs/heads/*:refs/remotes/origin/*
       > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
       > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
      Checking out Revision 2f804a136362d47e3a62e16bd54382ff5723a2ee (refs/remotes/origin/master)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 2f804a136362d47e3a62e16bd54382ff5723a2ee
      Commit message: "fds"
       > git rev-list --no-walk b8b9b5c00b6af662dbc3117e30f0b655fa1285d6 # timeout=10
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Run maven)
      [Pipeline] container
      [Pipeline] {
      [Pipeline] sh
      [jenros_testing] Running shell script
      sh: /home/jenkins/workspace/ZZ - Test/<<REDACTED>>@tmp/durable-333a089f/script.sh: not found
      [Pipeline] }
      [Pipeline] // container
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 127
      Finished: FAILURE

      My pod template setup is the following:

      My goal is to be able to run commands/actions on various docker containers but as of right now this doesn't appear to be working.

       

            iocanel Ioannis Canellos
            vdinicola Vincent Dinicola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: