how to fetch agent pod template from different repository in jenkins pipeline

5/22/2020

I want to keep jenkins pipeline agents (kubernetes pod) templates in Repo A. The jenkinsfile is in Repo B. To run stage 'ci' on Repo B, I need agents folder checked out from Repo A.

pipeline {
  agent none
  stages {
    stage('ci') {
      agent {
        kubernetes {
          yamlFile "agents/ci.yaml"
        }
      }
      steps {
      }
    }
    stage('staging deploy') {
      agent {
        kubernetes {
          yamlFile "agents/stage-deploy.yaml"
        }
      }
      steps {
      }
    }
  }
}

When I run jenkins pipeline job, it checks out Repo B (branch name = develop). But I am not able to checkout Repo A (branch name = master) to get the agents templates. Any help here would be great. I have been struggling around this a lot.

-- Shadja Chaudhari
jenkins
jenkins-git-plugin
jenkins-groovy
jenkins-kubernetes
jenkins-pipeline

0 Answers