Can HTML submit button trigger a Jenkins job ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Can HTML submit button trigger a Jenkins job ?

Shifa Shaikh

My HTML code is like below where i pass the crumb and try to trigger a Jenkins DSL job along with passing parameters:

<html>
<body>
<tr>
<td>
<form action='https://localhost:8080/job/myjob1/buildWithParameters?paramone=myhost1-stop-myfolder -H Jenkins-Crumb:d863847724897hghjtg37684yh4j3y9847dsfhkuhd' method=POST><input type='submit' value='START'/>
</form>
</td>
</tr>
</body>
</html>

On the browser i see the URL as:

https://localhost:8080/job/myjob1/buildWithParameters?paramone=myhost1-stop-myfolder%20-H%20Jenkins-Crumb:d863847724897hghjtg37684yh4j3y9847dsfhkuhdI

I frankly have no idea how can I pass the crumb using HTML submit button.


I had obtained my crumb from https://localhost:8080/crumbIssuer/api/xml


When i click on START button i get 


HTTP ERROR 403 No valid crumb was included in the request


My Jenkins has SAML based SSO for login and I would like the user triggering the START button to login with his credentials hence, I do not pass the credentials in the URL.


The job myjob1 is configured to be triggered remotely.


Also, I'm able to trigger the job using curl utility but not sure how-to using HTML button.


Can you please suggest how to get this to work?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8d5e3e1a-5adc-4b96-8fdc-d5765ccf5dd8o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Can HTML submit button trigger a Jenkins job ?

jeremy mordkoff
simple answer is no. an href cannot include a headers directive or anything else)

It can be done using ajax -- https://stackoverflow.com/questions/374885/can-i-change-the-headers-of-the-http-request-sent-by-the-browser 

or you could build a proxy that did nothing but add that header. But if you do that, you might as well allow anonymous users to start jobs and then the header becomes superfluous (I think). 

On Sunday, November 1, 2020 at 1:49:16 PM UTC-5 [hidden email] wrote:

My HTML code is like below where i pass the crumb and try to trigger a Jenkins DSL job along with passing parameters:

<html>
<body>
<tr>
<td>
<form action='https://localhost:8080/job/myjob1/buildWithParameters?paramone=myhost1-stop-myfolder -H Jenkins-Crumb:d863847724897hghjtg37684yh4j3y9847dsfhkuhd' method=POST><input type='submit' value='START'/>
</form>
</td>
</tr>
</body>
</html>

On the browser i see the URL as:

https://localhost:8080/job/myjob1/buildWithParameters?paramone=myhost1-stop-myfolder%20-H%20Jenkins-Crumb:d863847724897hghjtg37684yh4j3y9847dsfhkuhdI

I frankly have no idea how can I pass the crumb using HTML submit button.


I had obtained my crumb from https://localhost:8080/crumbIssuer/api/xml


When i click on START button i get 


HTTP ERROR 403 No valid crumb was included in the request


My Jenkins has SAML based SSO for login and I would like the user triggering the START button to login with his credentials hence, I do not pass the credentials in the URL.


The job myjob1 is configured to be triggered remotely.


Also, I'm able to trigger the job using curl utility but not sure how-to using HTML button.


Can you please suggest how to get this to work?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e2cc978b-5c82-441e-abd6-ff489b557bban%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Can HTML submit button trigger a Jenkins job ?

kuisathaverat
also, if your authentication is SAML, you will have to use an API Token to call the API. SAML delegate the authentication in your IdP so Jenkins does not process your User and Password only the TOKEN generated by your IdP. 

El lunes, 2 de noviembre de 2020 a las 18:17:00 UTC+1, [hidden email] escribió:
simple answer is no. an href cannot include a headers directive or anything else)


or you could build a proxy that did nothing but add that header. But if you do that, you might as well allow anonymous users to start jobs and then the header becomes superfluous (I think). 

On Sunday, November 1, 2020 at 1:49:16 PM UTC-5 [hidden email] wrote:

My HTML code is like below where i pass the crumb and try to trigger a Jenkins DSL job along with passing parameters:

<html>
<body>
<tr>
<td>
<form action='https://localhost:8080/job/myjob1/buildWithParameters?paramone=myhost1-stop-myfolder -H Jenkins-Crumb:d863847724897hghjtg37684yh4j3y9847dsfhkuhd' method=POST><input type='submit' value='START'/>
</form>
</td>
</tr>
</body>
</html>

On the browser i see the URL as:

https://localhost:8080/job/myjob1/buildWithParameters?paramone=myhost1-stop-myfolder%20-H%20Jenkins-Crumb:d863847724897hghjtg37684yh4j3y9847dsfhkuhdI

I frankly have no idea how can I pass the crumb using HTML submit button.


I had obtained my crumb from https://localhost:8080/crumbIssuer/api/xml


When i click on START button i get 


HTTP ERROR 403 No valid crumb was included in the request


My Jenkins has SAML based SSO for login and I would like the user triggering the START button to login with his credentials hence, I do not pass the credentials in the URL.


The job myjob1 is configured to be triggered remotely.


Also, I'm able to trigger the job using curl utility but not sure how-to using HTML button.


Can you please suggest how to get this to work?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0bc457fd-4299-4fb7-8a0f-fb53a80175ebn%40googlegroups.com.