I want to invoke another Jenkins build job through groovy , How I can do that . I tried with including like below but no luck
build 'job url'
but got the error
ERROR: No parameterized job named
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.
Under Build Section, Add Trigger a remote parameterized job as a build step. Then select the Destination Jenkins name that we just added, give the job name that you want to trigger at destination Jenkins(here it is test ) and parameters. Once saved, trigger the source Jenkins job.
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. } } } } Note: The build step can be used to call any project.
There are three main steps needed to perform: Create an authentication token in Jenkins. Configure a job to trigger from remote in Jenkins. Trigger the jenkins job via curl.
If you are using Pipeline Plugin and you want to build a parametrized job you can do:
Supose you have a "sonar-review" boolean parameter:
build job: 'cargo-pipeline-ci-declarative', parameters: [booleanParam(name: 'sonar-review', value: false)]
In case you don't required to build a job without parameters:
You can just do:
build "cargo-pipeline-ci-declarative"
Be sure you have installed:
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin
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