← Back to team overview

python-jenkins-developers team mailing list archive

[Bug 1879629] [NEW] Possible to support /wfapi

 

Public bug reported:

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - 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>/<job>/<id>/wfapi/

To approve, post to http://<jenkins_host>/<job>/<id>/wfapi/inputSubmit?inputId=<input_id> with payload data if you have more parameters accepts by input, e.g.
```
{'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>/<job>/<id>/input/<input_id>/abort

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
I'd liket to have some function wrapped here, so that I do not need to make a http request every time...

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

##### USEFUL INFORMATION
<!---
For bugs, show exactly how to reproduce the problem.
For new features, show how the feature would be used.
-->

<!--- Paste example code and full stacktrace below -->
```
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)
```

** Affects: python-jenkins
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1879629

Title:
  Possible to support /wfapi

Status in Python Jenkins:
  New

Bug description:
  ##### ISSUE TYPE
  <!--- Pick one below and delete the rest: -->
   - 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>/<job>/<id>/wfapi/

  To approve, post to http://<jenkins_host>/<job>/<id>/wfapi/inputSubmit?inputId=<input_id> with payload data if you have more parameters accepts by input, e.g.
  ```
  {'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>/<job>/<id>/input/<input_id>/abort

  ##### EXPECTED RESULTS
  <!--- What did you expect to happen when running the steps above? -->
  I'd liket to have some function wrapped here, so that I do not need to make a http request every time...

  ##### ACTUAL RESULTS
  <!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

  ##### USEFUL INFORMATION
  <!---
  For bugs, show exactly how to reproduce the problem.
  For new features, show how the feature would be used.
  -->

  <!--- Paste example code and full stacktrace below -->
  ```
  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)
  ```

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1879629/+subscriptions