When creating a Jenkinsfile I'd like to read the pom template from an external yaml, and not from embedded yaml in the agent definition yaml field which is harder to edit

          [JENKINS-52259] Read pod template yaml from external file

          Andrew Bayer added a comment -

          I think the solution here is to add a yamlFile or whatever parameter for the Kubernetes agent type, and modify KubernetesDeclarativeAgentScript to check if that parameter is given, and then assuming it is and the scm object in the Pipeline context is non-null (i.e., this is either a multibranch Pipeline or a standalone Pipeline with "Pipeline from SCM"), it would use readTrusted to load the yaml and pass it on from there. Seems pretty simple.

          Andrew Bayer added a comment - I think the solution here is to add a yamlFile or whatever parameter for the Kubernetes agent type, and modify KubernetesDeclarativeAgentScript to check if that parameter is given, and then assuming it is and the scm object in the Pipeline context is non-null (i.e., this is either a multibranch Pipeline or a standalone Pipeline with "Pipeline from SCM"), it would use readTrusted to load the yaml and pass it on from there. Seems pretty simple.

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Got a preliminary PR up at https://github.com/jenkinsci/kubernetes-plugin/pull/355

          Merged in 1.10.0

          Carlos Sanchez added a comment - Merged in 1.10.0

          Using yamlFile does not work with parameterized git branch builds.

          I'm getting the following exception when the plugin tries to load the file:

          hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH} --prune" returned status code 128:
          stdout: 
          stderr: fatal: Couldn't find remote ref refs/heads/${BRANCH}
          

          David Heidrich added a comment - Using yamlFile does not work with parameterized git branch builds. I'm getting the following exception when the plugin tries to load the file: hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH} --prune" returned status code 128: stdout: stderr: fatal: Couldn't find remote ref refs/heads/${BRANCH}

          David Heidrich added a comment - - edited

          csanchez. See my previous comment regarding parameterized builds and declarative pipeline.

          David Heidrich added a comment - - edited csanchez . See my previous comment regarding parameterized builds and declarative pipeline.

          isn't that JENKINS-52623 ?
          please do not reopen, and file a new issue instead if that's not the case

          Carlos Sanchez added a comment - isn't that JENKINS-52623 ? please do not reopen, and file a new issue instead if that's not the case

          Ajith Krishna added a comment - - edited

          podTemplate(label: slave_label, cloud: "${cloud_name}", readFile : 'deploy.yml' ) {
           
          }
           
          i used deploy.yml and added all pod , namespace , name , image and resources etc.
          but pod is not creating . its not even reading the yaml file. instead its going to docker hub internet. but my image is in my own artifactory . i checked kubernetes dashboard pod is not creating due jnlp was not created.
          error is like pod bddrunner(my pod mentioned in yaml file) is offline
          please help me to fix it.
           
          yaml file:
          apiVersion: v1
          kind: Pod
          metadata:
          name: bdd-runner
          namespace: edison-core
          spec:
          containers:

          • name: 'jnlp'
            image: 'myartifactory/jenkins/jnlp-slave:3.10-1-alpine'
            command:
          • cat
            tty: true
          • name: 'custom-slave'
            image: 'my artifactorydocker-snapshot-abs/eis-test-data/absdata:latest'
            command:
          • cat
            tty: true

          Ajith Krishna added a comment - - edited podTemplate(label: slave_label, cloud: "${cloud_name}", readFile : 'deploy.yml' ) {   }   i used deploy.yml and added all pod , namespace , name , image and resources etc. but pod is not creating . its not even reading the yaml file. instead its going to docker hub internet. but my image is in my own artifactory . i checked kubernetes dashboard pod is not creating due jnlp was not created. error is like pod bddrunner(my pod mentioned in yaml file) is offline please help me to fix it.   yaml file: apiVersion: v1 kind: Pod metadata: name: bdd-runner namespace: edison-core spec: containers: name: 'jnlp' image: 'myartifactory/jenkins/jnlp-slave:3.10-1-alpine' command: cat tty: true name: 'custom-slave' image: 'my artifactorydocker-snapshot-abs/eis-test-data/absdata:latest' command: cat tty: true

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            csanchez Carlos Sanchez
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: