jenkinsapi
jenkinsapi copied to clipboard
Possible to support /wfapi
ISSUE TYPE
- Feature Idea
Jenkinsapi VERSION
Jenkins VERSION
SUMMARY
As some mentioned in #764, user input is part of the job.
Something I've done to automated Jenkins user input via /wfapi for our slack interaction.
Refer to : http://<jenkins_host>/
To approve, post to http://<jenkins_host>/
{'parameter': [
{
'name': 'adname',
'value': ad_account_mapping[d['user']['id']]
},
{
'name': 'approved_by_slack_id',
'value': d['user']['id']
},
{
'name': 'slack_response_url',
'value': d['response_url']
}
]}
To deny, post to http://<jenkins_host>/
EXPECTED RESULTS
I'd liket to have some function wrapped here, so that I do not need to make a http request every time...
ACTUAL RESULTS
USEFUL INFORMATION
headers = {'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}
build_url = approval_result+'wfapi/inputSubmit'
querystring = {"inputId":"testid"}
payload = {'json':json.dumps({'parameter': [
{
'name': 'p1',
'value': 'v1'
},
{
'name': 'p2',
'value': ''v2'
}
]})}
resp = requests.post(build_url, headers=headers, auth=('jenkins-user', 'jenkins-token'), data=payload, params=querystring)
I also came across this issue, wfapi only supports the JSON API. One solution could be to have a simple converter between Python API and JSON API. I had a look at the responses and they are very similar, exept, e.g. Python API: JSON API None: null True: true False: false