Hope you can help me on this one. I have a job called "Template" that generates a template.xml file. I have several other jobs that use this template.xml file. However, before they build, i wanted that they could pull the latest template.xml from the "Template" job workspace.
You can follow the below steps to trigger a Jenkins pipeline in another Jenkins pipeline. Select a job that triggers a remote one and then go to Job Configuration > Build section > Add Build Step > Trigger builds on remote/local projects option.
I used Copy Artifacts plugin with Jenkinsfile. Here an example:
In the job that is producing the artifact you should do something like:
pipeline {
options {
copyArtifactPermission ‘*’ //Here you can specify the job name also
}
stages {
stage(“Run") {
...
archiveArtifacts artifacts: “my_artifact.yaml"
}
}
}
In the job that is consuming the artifact you can use something like:
stage("Consumer") {
steps {
script {
copyArtifacts filter: “my_artifact.yaml", projectName: 'PRODUCER_JOB',
selector: lastSuccessful()
}
}
}
In your "template" job, under Post-Build Actions, choose to artifact your xml file using the archive option.
You can then use the "Copy Artifact Plugin" to copy it over to all other jobs.
Jenkins Job Setup for Artifact Generator Project
:
Jenkins Job Setup for Artifact User Project
:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With