tags:

views:

49

answers:

1

We have a hudson server which deploys builds. We have a few services which we want to be able to remotely tell hudson to deploy a certain build ... these services are using ant. So I'm trying to get it working but keeping getting a 403 response when giving a build number like so...

<ac:post    to="http://hostname:8080/hudson/job/test_release_indexes/build?"
    verbose="true" wantresponse="true">
        <prop name="token" value="indexes"/>
        <prop name="BUILDNUMBER" value="0354"/>
</ac:post> 

this throws the 403. I've also tried passing it props for the username and password like so ...

<ac:post to="http://srulesre2:8080/hudson/job/test_dartmouth_indexes/build?"
    verbose="true" wantresponse="true">
        <prop name="token" value="indexes"/>
        <prop name="BUILDNUMBER" value="0354"/>
        <prop name="username" value="test"/>
        <prop name="password" value="test"/>
</ac:post>

I've tried a hundred different variations on username and password ... like j_username and j_password or user and pass ... but nothing is working ... keep getting the same 403. And the username and password are valid because I can manually log in with admin privileges. Any ideas would be great

A: 

Can you do a view source on the Hudson login screen to see what fields the form takes? I dont have a running instance myself.

JoseK
So I thought the same thing and seen that it takes j_username and j_password as fields for logging in. So I tried to do a post with the login screen like so <ac:post to="http://<servername>:8080/hudson/login? from=/hudson/log/all" verbose="true" wantresponse="true"> <prop name="j_username" value="test"/> <prop name="j_password" value="test"/> </ac:post>but still get a 403.
Christopher Dancy
In my experience, there's a script that wraps form parameters into json. You might need to try something like http://stackoverflow.com/questions/2201843/submitting-a-parameterized-hudson-build-via-the-rest-api/2202137#2202137
Dave Bacher
Or if you look at Ant Fikin which specifically has examples for posting username/password http://fikin-ant-tasks.sourceforge.net/fikin-ant-tasks.html#httppost
JoseK
I tried the Ant Fikin task and still get the same 403 error. If it makes any difference the logs say that "No valid crumb was included in the request"
Christopher Dancy
Could it be a Hudson bug for specific versions as here http://n4.nabble.com/JIRA-Created-HUDSON-5717-No-valid-crumb-on-manual-build-request-td1561925.html
JoseK
That's possible ... However as of yesterday night we've given up that route and gone another way ... a bit more cumbersome bit it works. Dave I tried getting it done with json but it simply was not working and I can't spend any more time on it. I'll just chalk this up to hudson not being as user friendly as it should. But thanks anyway guys.
Christopher Dancy