4
votes

I am using Jenkins along with Parameterized Trigger Plugin for triggering a job remotely. The build trigger is failed with console output as below

Server returned HTTP response code: 403 for URL: http://x.x.x.x:8080/job/jobname/buildWithParameters?token=buildcommand&build&delay=0
Connection to remote server failed, waiting for to retry - 10 seconds until next attempt.
Retry attempt #1 out of 5
Server returned HTTP response code: 403 for URL: http://x.x.x.x:8080/job/jobname/buildWithParameters?token=buildcommand&build&delay=0
Connection to remote server failed, waiting for to retry - 10 seconds until next attempt.
ERROR: Remote build failed for the following reason:

The build with URL 'http://x.x.x.x:8080/job/jobname/build?token=buildcommand&build&delay=0' from a browser is able to trigger the build remotely.

I only see the difference between two URL is one uses 'build' and other has 'buildWithParameters'.

Could you please help me to resolve the same.

1
Found same issue. Also found You must use POST method to trigger builds. while click on above console links. - Sagar007

1 Answers

5
votes

Had the same issue where my remote jenkins was using credentials that were passed in by the master build. To fix it I had to disable CSRF protection on the target Jenkins:

  1. Log into your target Jenkins and go to Manage Jenkins
  2. Go to Configure Global Security
  3. Scroll down to Prevent Cross Site Request Forgery exploits
  4. Uncheck it
  5. Save changes

No need to restart Jenkins, just try the master job again.

Caveat: Obviously your Jenkins server is without CSRF protection... but it's probably safely behind a corporate firewall anyway, right?