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.
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.
In your Template
job, you can archive the template.xml file as an artifact, then it will be available to your other jobs at a URL similar to the following:
http://myserver/jenkins/job/myjob/lastSuccessfulBuild/artifact/template.xml
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 my end I use a pretty strainghforward approach. I run jenkins in a usual layout (ubuntu 16.04 server) and I need call the checkstyle maven plugin using the same checkstyle.xml config file residing inside a dev-resources job:
Than I call mvn checkstyle:
Hope it can be useful for someone else.
© 2022 - 2024 — McMap. All rights reserved.