Quantcast

Incoherence in links build project

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Incoherence in links build project

Ramón Rial
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.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Incoherence in links build project

Ramón Rial
Sorry. It was a problem of my error code.
This thread can be closed.

El jueves, 30 de agosto de 2012 10:18:32 UTC+2, Ramón Rial escribió:
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.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Incoherence in links build project

Ramón Rial
In reply to this post by Ramón Rial
The problem is still there. My last post was not ok. So I think there is a bug.
I understand that the AJAX call is great for user experience, but it is an incoherence two different calls for the same action: one GET and one POST.
And when the only way to detect if we sended the parameters (build parameterized) is the method call, that for now works great because it has no considered the posibility of showing a similar page when there are no build parameters.

El jueves, 30 de agosto de 2012 10:18:32 UTC+2, Ramón Rial escribió:
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.


Loading...