How to convert action method to POST type in Jenkins/Hudson

85 views Asked by At

I have implemented Action to create customized method url.

getURL(){ "sampleURL"}

doBuildNow(){//Method implementation}

So Here URL : http://hostserver/job/jobName/sampleURL/buildNow

I would like to use this method as POST which doesn't work by default, I didn't find any clue from google search. Can any one please help me on this.

1

There are 1 answers

0
George S On

In order to force a Jenkins action method to only accept a post, add the '@RequirePOST' annotation to the method.

@RequirePOST
doBuildNow(){//Method implementation}

This has the added benefit of automatically providing a 'Try POSTing' button when someone does a get via the browswer.

This is the behavior seen in Jenkins when accessing the '/exit' url.