Repository: pycontribs/jenkinsapi

Issue:
jenkinsapi.build.get_params() fails when Job have password parameter
##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### Jenkinsapi VERSION
0.3.4
##### Jenkins VERSION
Jenkins ver. 2.60.2
##### SUMMARY
When Job have Password Parameter and I try to get build parameters of this job ( jenkinsapi.build.get_params() ), procedure get_params() fails with traceback:

```
Traceback (most recent call last):
  File "/opt/pycharm/helpers/pydev/pydevd.py", line 1599, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/opt/pycharm/helpers/pydev/pydevd.py", line 1026, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/opt/pycharm/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/tema/Pro/Jenins-job-restart/jjr.py", line 320, in <module>
    jjr.start()
  File "/home/tema/Pro/Jenins-job-restart/jjr.py", line 50, in start
    self.__cycle()
  File "/home/tema/Pro/Jenins-job-restart/jjr.py", line 100, in __cycle
    job_params = job_build.get_params()
  File "/home/tema/Pro/ve_Jenkins/lib/python3.5/site-packages/jenkinsapi/build.py", line 110, in get_params
    return {pair['name']: pair['value'] for pair in parameters}
  File "/home/tema/Pro/ve_Jenkins/lib/python3.5/site-packages/jenkinsapi/build.py", line 110, in <dictcomp>
    return {pair['name']: pair['value'] for pair in parameters}
KeyError: 'value'
```

because value "parameters" in get_params():

`[{'name': 'BRANCH', '_class': 'hudson.model.StringParameterValue', 'value': 'staging'}, {'name': 'REPO_URL', '_class': 'hudson.model.StringParameterValue', 'value': 'git.my.com:/BB.git'}, {'name': 'NODE', '_class': 'org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterValue', 'value': 'my11'}, {'name': 'DOMAIN', '_class': 'hudson.model.StringParameterValue', 'value': 'my.lan'}, {'name': 'SETUP', '_class': 'hudson.model.BooleanParameterValue', 'value': True}, {'name': 'LAUNCH', '_class': 'hudson.model.BooleanParameterValue', 'value': True}, {'name': 'REBUILD', '_class': 'hudson.model.StringParameterValue', 'value': 'No_Force'}, {'name': 'JENKINS_TESTS', '_class': 'hudson.model.BooleanParameterValue', 'value': False}, {'name': 'DR_REGISTRY', '_class': 'hudson.model.StringParameterValue', 'value': 'dr.my.lan:5000'}, {'name': 'TESTS_LISTS', '_class': 'com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterValue', 'value': 'registration_actions'}, {'name': 'CURRENCY', '_class': 'hudson.model.StringParameterValue', 'value': 'EUR'}, {'name': 'DEFAULT_LANG_CODE', '_class': 'hudson.model.StringParameterValue', 'value': 'en'}, {'name': 'SELENIUM_HOST', '_class': 'hudson.model.StringParameterValue', 'value': my2.my.lan'}, {'name': 'GET_JS_ERRORS', '_class': 'hudson.model.BooleanParameterValue', 'value': False}, {'name': 'OPERATOR_ID', '_class': 'hudson.model.StringParameterValue', 'value': '15'}, {'name': 'OPERATOR_API_SERVER_URL', '_class': 'hudson.model.StringParameterValue', 'value': 'op.my.com:8043'}, {'name': 'USER_API_SERVER_HOST', '_class': 'hudson.model.StringParameterValue', 'value': 'cw-gm.my.com'}, {'name': 'EXTERNAL_OP_HOST', '_class': 'hudson.model.StringParameterValue', 'value': 'my.com'}, {'name': 'MOBILE_SITE_URL', '_class': 'hudson.model.StringParameterValue', 'value': 'm.my.com'}, {'name': 'BO_SERVER_HOST', '_class': 'hudson.model.StringParameterValue', 'value': 'bo.my.com'}, {'name': 'PREPROD', '_class': 'hudson.model.BooleanParameterValue', 'value': True}, {'name': 'OPERATOR_PASSWORD', '_class': 'hudson.model.PasswordParameterValue'}, {'name': 'FB_APPID', '_class': 'hudson.model.PasswordParameterValue'}, {'name': 'FB_SECRET', '_class': 'hudson.model.PasswordParameterValue'}]
`

last key pairs (OPERATOR_PASSWORD FB_APPID FB_SECRET) don't have key 'value' because its "Password Parameters"

##### EXPECTED RESULTS
Key 'value' must return at least an empty string.

##### ACTUAL RESULTS
Procedure fails with traceback written above.

##### USEFUL INFORMATION
All info in ##### SUMMARY


Comments:

Patch:
diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py
index 2e142da..e220b61 100644
--- a/jenkinsapi/build.py
+++ b/jenkinsapi/build.py
@@ -106,7 +106,7 @@ class Build(JenkinsBase):
                 if elem.get('_class') == 'hudson.model.ParametersAction':
                     parameters = elem.get('parameters', {})
                     break
-            return {pair['name']: pair['value'] for pair in parameters}
+            return {pair['name']: pair.get('value') for pair in parameters}
 
     def get_changeset_items(self):
         """
diff --git a/tox.ini b/tox.ini
index a5aac73..16b7cc1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -22,7 +22,7 @@ usedevelop=
 commands=
   python -m pylint jenkinsapi
   python -m pycodestyle
-  py.test -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests
+  py.test -sv --cov=jenkinsapi --cov-report=term-missing --cov-report=xml jenkinsapi_tests {posargs}
 
 [testenv:args]
 deps = -rtest-requirements.txt


Test patch:
diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py
index fe31972..8df3adf 100644
--- a/jenkinsapi_tests/unittests/test_build.py
+++ b/jenkinsapi_tests/unittests/test_build.py
@@ -157,6 +157,25 @@ def test_only_ParametersAction_parameters_considered(build):
     assert params == expected
 
 
+def test_ParametersWithNoValueSetValueNone_issue_583(build):
+    """SecretParameters don't share their value in the API."""
+    expected = {
+        'some-secret': None,
+    }
+    build._data = {
+        'actions': [
+            {
+                '_class': 'hudson.model.ParametersAction',
+                'parameters': [
+                    {'name': 'some-secret'},
+                ]
+            }
+        ]
+    }
+    params = build.get_params()
+    assert params == expected
+
+
 def test_build_env_vars(monkeypatch, build):
     def fake_get_data(cls, tree=None, params=None):
         return configs.BUILD_ENV_VARS