I think you want to pass the username/password as part of the Open method call
HttpReq.Open "POST", strJenkinsURL, False, strUsername, strPassword In addition, you may need to set an Authorization header, but I am not sure how the MSXML2.ServerXMLHTTP object handles that if you pass the username/password with the Open call. You would need to do something like this if just passing it via the Open method doesn't work: HttpReq.setRequestHeader "Authentication", "Basic " & Base64Encode(strUsername & ":" & strPassword) On Tue, Jul 9, 2019 at 10:54 AM D. C. <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/jenkinsci-users/acd05793-f5c3-47c1-9049-75835b7933a2%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Website: http://earl-of-code.com -- 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/CAPiUgVd%3DGrnaUdGi3i9j4ZtHT1H7Gzsf_1ce2EWqhpaPawSZRg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
