Getting “I forgot what I was talking about” when making this ^jsonopen(direct POST) call. I can see a server exception in the log file. bugs.txt contains a stack problem output. The previous ^jsonopen (GET) is working with no problem.
I only have this problem when the POST call is successful. If there is an error jenkins returns html, which I pass on as my result and it displays just fine.
When the bot’s userid on the jenkins server didn’t have permissions, this call would get a 403 denied and returned html which I could then display (that’s why i am using direct) Now that I have the permissions setup there are no 403 errors (%httpresponse is 201) and the build is started and chatscript gives a server error and never executes any code after the ^jsonopen(POST). Executing the json call using curl also starts the build and returns a 201 and curl reports that 0 is returned.
here is the code, logfile, and bugs.txt contents
Code:
u: GET_CRUMB ($$_haveVars)
$$_crumburl = ^"$jenkinsServerUrl/crumbIssuer/api/json?xpath=concat(//crumbRequestField,\":\",//crumb)"
^log(^"\n calling for a crumb")
^nofail( INPUT $$_crumb = ^jsonopen( GET $$_crumburl "" $$_headers) )
^log(^"\n back from getting the crumb... httpresponse: %httpresponse, crumb: $$_crumb")
u: DO_TASK($$_crumb $$_haveVars)
^log(\n starting the task)
$$_url = ^"$jenkinsServerUrl/job/$jenkinsCurJobName/build?token=42SalesBuildToken90210$jenkinsCurJobName&cause=Lisa_initiated_for_%user"
$$_headers = ^"$$_crumb.crumbRequestField:$$_crumb.crumb"
^log( ^"\n calling: $$_url with headers: $$_headers")
^nofail( INPUT $$_rawinfo = ^jsonopen(direct POST $$_url "" $$_headers) )
^log(^"\n back from call $$_url \n info: $$_rawinfo ")
if( %httpresponse == 201){
# $$_info = ^jsonparse(NOFAIL $$_rawinfo)
# ^log(^"\n got this json back: ^jsontree($$_info)")
build has begun for $jenkinsCurJobName on $jenkinsServerId
}else{
^log(^"\n got undesired httpresponse of: %httpresponse \n $$_rawinfo ")
^setgoalproblem(^"received code %httpresponse \n $$_rawinfo")
}
Log:
calling for a crumb
....,....,...........Json method/url: GET http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/crumbIssuer/api/json?xpath=concat(//crumbRequestField,":",//crumb)
....,....,...........Json open time: 32 ms for GET http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/crumbIssuer/api/json?xpath=concat(//crumbRequestField,":",//crumb)
....,....,...........JsonParse Call: {"_class":"hudson.security.csrf.DefaultCrumbIssuer","crumb":"2231e9351c46d926b05f2226911528da","crumbRequestField":"Jenkins-Crumb"}
....,....,...........JSON response: 200 size: 131 - {"_class":"hudson.security.csrf.DefaultCrumbIssuer","crumb":"2231e9351c46d926b05f2226911528da","crumbRequestField":"Jenkins-Crumb"}
....,....,...........
back from getting the crumb... httpresponse: 200, crumb: jo-t1021
....,....,.........try u:6.0 DO_TASK @0: pattern: ( $$_crumb $$_havevars )
....,....,.........( $$_crumb(jo-t1021)+ $$_havevars(1)+ )+
....,....,......... ** Match: u: DO_TASK ( $$_crumb $$_havevars ) ^log ( \n starting the task ) $$_url = ^"$jenkinsServerUrl/job/$j...
starting the task(jo-t1021.crumbRequestField->``Jenkins-Crumb)(jo-t1021.crumb->``2231e9351c46d926b05f2226911528da)
calling: http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/job/sales_dental-enrollment-portlet/build?token=42SalesBuildToken90210sales_dental-enrollment-portlet&cause=Lisa_initiated_for_stephen with headers: Jenkins-Crumb:2231e9351c46d926b05f2226911528da
....,....,...........Json method/url: POST http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/job/sales_dental-enrollment-portlet/build?token=42SalesBuildToken90210sales_dental-enrollment-portlet&cause=Lisa_initiated_for_stephen
....,....,...........Json header: Jenkins-Crumb:2231e9351c46d926b05f2226911528da
....,....,...........
....,....,...........Json data 0 bytes:
....,....,...........Json open time: 93 ms for POST http://lisa:ac63b4e532ae4518cefd8a21a1f0a1b3@bcdevsrv058:8080/job/sales_dental-enrollment-portlet/build?token=42SalesBuildToken90210sales_dental-enrollment-portlet&cause=Lisa_initiated_for_stephen
Catch Server exception
1 Fri Feb 23 14:25:59 2018 in sentence: please build dental on dev jenkins
***Server exception0
1 Fri Feb 23 14:25:59 2018 in sentence: please build dental on dev jenkins
bugs.txt: is attached.