I have searched all over but haven't found a solution to this. The 
JenkinsAPI page doesn't provide information on using VBScript either.
I am trying to start a job in Jenkins from a classic ASP web page (so 
VBScript - code below).  I used wget from examples on the Jenkins API page 
to get the Jenkins crumb. The testjob is configured with "Trigger builds 
remotely" and I included the token in the URL string as specified in the 
examples on the Jenkins API page. I am unsure if the login information is 
setup correctly in my .setRequestHeader, but the error I am getting is "No 
valid crumb" even though I include the crumb in the header.  Can anyone 
tell me if the .setRequestHeaders are in the correct format or anything 
else that might help me get this to work?  I have also tried using curl to 
start the job, but that doesn't start the job, but it also doesn't return 
an error. From what I have found, curl should return an HTTP 201 response 
to indicate the job was started. I'm not getting that.  I would prefer to 
start the job from VBScript; curl was just for a test.

VBScript:
--------------
    Dim strJenkinsURL, HttpReq
    strJenkinsURL = 
"http://<jenkinsURL>/job/testjob/buildWithParameters?token=test&Description=sometext"

    Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
    HttpReq.Open "POST", strJenkinsURL, False
    HttpReq.setRequestHeader "UserName", "<jenkinsuser>"
    HttpReq.setRequestHeader "Password", "<userpassword>"
    HttpReq.setRequestHeader "Jenkins-Crumb", "<validcrumb>"
    HttpReq.Send
    Response.Write "<br>Status: "& HttpReq.Status & vbNewline
    Response.Write "<br>Response: "& HttpReq.responseText & vbNewline

Result
---------------------
Status: 403
Response: HTTP ERROR 403
Problem accessing /job/testjob/buildWithParameters. Reason: No valid crumb 
was included in the request

curl:
------------------------
curl -v --user <jenkinsuser>:<password> -X POST 
"http://jenkinsurl/job/testjob/buildWithParameters?token=test&Description=sometext";
 
-H "Jenkins-Crumb:<crumb value>"

* timeout on name lookup is not supported
*   Trying xxx.xxx.xxx.xxx...
* TCP_NODELAY set
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  
Current
                                 Dload  Upload   Total   Spent    Left  
Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- 
--:--:--     0* Connected to jenkinsurl (xxx.xxx.xxx.xxx) port 80 (#0)
* Server auth using Basic with user 'jenkinsuser'
> POST /job/testjob/buildWithParameters?token=test&Description=sometext 
HTTP/1.1
> Host: jenkinsurl
> Authorization: Basic Y3MyYXV0b3Rlc3Q6QXV0b21hdGlvbjE=
> User-Agent: curl/7.55.0
> Accept: */*
> Jenkins-Crumb:<crumb value>
>
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Found
< Location: 
https://jenkinsurl/job/testjob/buildWithParameters?token=test&Description=sometext
< Server: BigIP
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
<
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- 
--:--:--     0
* Connection #0 to host jenkinsurl left intact

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/acd05793-f5c3-47c1-9049-75835b7933a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to