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.
You need to pull the repo with pod templates first, next reference the contents of the desired yaml file. The first stage needs to be executed on master node.
Here is the example of the pipeline:
I think you can create as many podTemplate variables as you need.