Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

triggering another jenkins job from jenkinsfile in pipeline

I am trying to invoke a separate jenkins job whose direct job url is https://jenkins.example.com/job/jobName/. This job runs with one parameter name "branch", whose value is "Master".

Below is how I am giving in my Jenkinsfile, but when I run it, gives me error

ERROR: No item named https://jenkins.example.com/job/jobName found

if ("${params.buildParam}" == 'test' || !params.buildParam ){
  stage('Test') {
    def job = build job: 'https://jenkins.example.com/job/jobName/', parameters: [[$class: 'StringParameterValue', name: 'branch', value: 'Master']]
  }
}
like image 578
learner Avatar asked Dec 02 '25 23:12

learner


1 Answers

The build step takes a job name as parameter, not a URL. So try

build job: '/jobName'

to refer using the absolute path. Depending on where your pipeline job is, you might use something like the following as well:

build job: '../../jobName/'

btw. you can avoid string interpolation here:

if (params.buildParam == 'test' ...)
like image 112
StephenKing Avatar answered Dec 05 '25 18:12

StephenKing