Issue
- I want a sample code of Declarative Pipeline which invokes another job
Environment
- CloudBees CI (CloudBees Core)
- CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
- CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
- CloudBees CI (CloudBees Core) on traditional platforms - Client controller
- CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
- CloudBees Jenkins Enterprise
- CloudBees Jenkins Enterprise - Managed controller
- CloudBees Jenkins Enterprise - Operations Center
- CloudBees Jenkins Team
- CloudBees Jenkins Platform - Client controller
- CloudBees Jenkins Platform - Operations Center
- Jenkins LTS
- Pipeline plugin
Resolution
pipeline { //indicate the job is written in Declarative Pipeline
agent any //agent specifies where the pipeline will execute.
stages {
stage ("build") { //an arbitrary stage name
steps {
build 'Pipeline_B' //this is where we specify which job to invoke.
}
}
}
}
You can use the Snippet Generator from Jenkins to generate the pipeline code. Snippet Generator can be accessed from ${JENKINS_HOME}/pipeline-syntax/
Note:
-
The build step can be used to call any project. The job which will be triggered does not have to be a pipeline.
-
You can pass additional build parameters as documented in Pipeline Build Step
0 Comments