Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i invoke another jenkins build job from groovy script

Tags:

jenkins

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

like image 224
Vin Avatar asked May 19 '17 19:05

Vin


People also ask

How do I trigger another build in Jenkins?

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.

How do I call one Jenkins job from another Jenkins job?

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.

How do you write a declarative pipeline to invoke another 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.

How do I trigger a Jenkins job using command line?

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.


1 Answers

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

like image 161
Daniel Hernández Avatar answered Sep 24 '22 18:09

Daniel Hernández