4

I've got a remote Jenkins job which does not require any login to start. This is a parameterized job, so it is normally started with "Build With Parameters".

When trying to trigger this build (with default parameters), I call the following:

wget [url_to_job]/build

And I get this error:

Connecting to 10.57.112.238:8080... connected.
HTTP request sent, awaiting response... 405 Method Not Allowed
2016-03-14 11:49:34 ERROR 405: Method Not Allowed.

From what I have read, I would think that this should work.

Am I doing something wrong?

juvchan
  • 5,555
  • 2
  • 20
  • 32
PortMan
  • 3,105
  • 4
  • 25
  • 45

4 Answers4

2
  1. First, the URL for Remote Trigger should be wget [url_to_job]/buildWithParameters not [url_to_job]/build.
  2. You can pass parameters by using wget [url_to_job]/buildWithParameters/?{parameterName}={parameterValue}
  3. Eg : http://localhost:8080/jenkins/job/test/buildWithParameters/?name=arun
arun kumar
  • 161
  • 3
  • 9
1

You better use curl instead of wget and also provide credentials for the command:

curl -XPOST --silent --show-error --user <user>:<key> <url_to_job>/build
yorammi
  • 5,012
  • 25
  • 32
0

wget --auth-no-challenge --delete-after --verbose "http://10.157.163.249:8080/job/scanning/buildWithParameters?token=scan&buildURL='abcdefg'"

Michael.Sun
  • 319
  • 4
  • 13
  • While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Yunnosch Dec 25 '20 at 15:35
0

The problem most likely is that you haven't copied the token over into the "Authentication Token" field of the build trigger. Clicking the checkbox isn't enough - Jenkins will silently remove the checkbox unless a token was provided.

Once I did this the following command worked:

wget --auth-no-challenge --user STRING --password STRING --output-document - 'http://localhost:8080/job/PROJECT/build?token=TOKEN'

Of course it is BAD PRACTICE to put passwords into scripts or the command line history. See this post to learn how to store the credentials in ~/.netrc.

Andreas Spindler
  • 6,185
  • 3
  • 37
  • 32