I am developing a plugin to customize the build process. The jenkins version for the plugin is 1.466.
The plugin should show a custom page with fixed parameters and the normal parameters defined at job, before starting the build, without having to define (the fixed parameters) as parameterized build. My problem is the following: 1) At jobs view (http://localhost/jenkins), the build link (schedule execution) renders: <a href="job/jobName/build?delay=0sec"> ... </a> And when I click the link sends EVER a GET request, although the job is not a parameterized build. 2) When I enter at job view in jenkins (http://localhost/jenkins/job/jobName), the build link renders: * When the job isn't a parameterized build: <a onclick="return build(this)" href="/jenkins/job/jobName/build?delay=0sec"> ... </a> *There is an extra onclick="return build(this)", that launch a POST request. * * When the job is a parameterized build: <a href="/jenkins/job/aaa/build?delay=0sec"> ... </a> *There is no the extra onclick, so launch a GET request.* * * To reproduce this problem you must: Create a new project of any type (for example, Maven 2 project), that it is not a parameterized build. Save changes. Examine the *Build now* link. It has the extra onclick="return build(this)". Now add a text parameter. Save changes. Examine the *Build now* link. It hasn't the extra onclick="return build(this)". I was examining the code hudson/model/AbstractProject.java (tag 1.466), for my plugin, the key is the method: public void doBuild( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { BuildAuthorizationToken.checkPermission(this, authToken, req, rsp); // if a build is parameterized, let that take over ParametersDefinitionProperty pp = getProperty(ParametersDefinitionProperty.class); if (pp != null) { pp._doBuild(req,rsp); return; } and following that, hudson/model/ParametersDefinitionProperty.java public void _doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { if(!req.getMethod().equals("POST")) { // show the parameter entry form. req.getView(this,"index.jelly").forward(req,rsp); return; } So we see the req.getMethod.equals("POST") is the solution for my problem, but Jenkins render different links that launch GET call at jobs view and GET or POST call at job view. So my code is not working when I launch the build from job view.
