405 Error when attempting to trigger remote Jenkins job with wget

Viewed 7831

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?

4 Answers

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

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.

Related