1

I have one jenkins server A where I am trying to create a scripted pipeline but I have to call another job (Job1) on another jenkins server B.

In order to do that I am using REST API with crumb in Header. I retrieve my crumb by running the following command on my browser. http://myhudson.com/crumbIssuer/api/json?xpath=concat(//crumbRequestField,":",//crumb)"

I tried different commands mentioned below but there is no luck.Please advise some thing. I do have access or permission for triggering build on both of the servers. I am executing below commands from Jenkins server A with details of Server B.

1. curl -v -u Username:<API_TOKEN> -X POST http://UsedrName:<API_TOKEN>@myjenkins.com/job/Test_job/build?token=<API_TOKEN> -H Jenkins-Crumb:<Crumb number>

2. curl -v -X POST http://UsedrName:<API_TOKEN>@myjenkins.com/job/Test_job/build?token=<API_TOKEN> -H Jenkins-Crumb:<Crumb number>

3. curl -v -u Username:<API_TOKEN> -X POST http://UsedrName:<API_TOKEN>@myjenkins.com/job/Test_job/build?token=<API_TOKEN> -H .crumb:<Crumb number>
daspilker
  • 8,154
  • 1
  • 35
  • 49
Debu
  • 19
  • 4

4 Answers4

0

did jenkins API work for you, https://wiki.jenkins.io/display/JENKINS/Remote+access+API you can trigger remote jobs

Ashokekumar S
  • 351
  • 3
  • 7
0

You need to use Build With Parameters Plugin for it . you can write a shell script in build option to call the another jenkins job on other server.

shell script snippet :curl -X POST -u userid of other server:API token of other server {jenkins server url of B job /job/jobname}

  • I did that but what I am getting following error "No valid crumb was included in the request". I then added additional parameter "-H Jenkins-Crumb:" but still I have got the same error. But after unchecking "Prevent Cross Site Request Forgery exploits" I am getting success. Now my concern is "Is it a good idea to uncheck cross site forgery". Could you please advise – Debu Jun 13 '18 at 10:32
0

I was able to execute remote parameter job.

SKH
  • 31
  • 3
0

I faced the same issue and it was because on that port something else is running and jenkins is giving Error as "No Valid crumb is included in that request" thus changed the port in server.xml and things worked.

Sanchi Girotra
  • 1,232
  • 13
  • 13