add support for EnvInject mask password params option

Added support for EnvInject mask password params option
Added unit test to cover inject_passwords in wrappers module

Change-Id: Ic6eb44cc6946f3f4636212868b6665dbde853c40
This commit is contained in:
Jaime Flynn 2015-01-20 15:12:56 -06:00
parent 4bf020e07e
commit 42670e9772
3 changed files with 29 additions and 7 deletions

View File

@ -600,23 +600,22 @@ def inject_passwords(parser, xml_parent, data):
<https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin>`_
:arg bool global: inject global passwords to the job
:arg bool mask-password-params: mask passsword parameters
:arg list job-passwords: key value pair of job passwords
:Parameter: * **name** (`str`) Name of password
* **password** (`str`) Encrypted password
Example::
Example:
.. literalinclude:: /../../tests/wrappers/fixtures/passwords001.yaml
wrappers:
- inject-passwords:
global: true
job-passwords:
- name: ADMIN
password: 0v8ZCNaHwq1hcx+sHwRLdg9424uBh4Pin0zO4sBIb+U=
"""
eib = XML.SubElement(xml_parent, 'EnvInjectPasswordWrapper')
XML.SubElement(eib, 'injectGlobalPasswords').text = \
str(data.get('global', False)).lower()
XML.SubElement(eib, 'maskPasswordParameters').text = \
str(data.get('mask-password-params', False)).lower()
entries = XML.SubElement(eib, 'passwordEntries')
passwords = data.get('job-passwords', [])
if passwords:

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<EnvInjectPasswordWrapper>
<injectGlobalPasswords>true</injectGlobalPasswords>
<maskPasswordParameters>true</maskPasswordParameters>
<passwordEntries>
<EnvInjectPasswordEntry>
<name>ADMIN</name>
<value>0v8ZCNaHwq1hcx+sHwRLdg9424uBh4Pin0zO4sBIb+U=</value>
</EnvInjectPasswordEntry>
</passwordEntries>
</EnvInjectPasswordWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,8 @@
wrappers:
- inject-passwords:
global: true
mask-password-params: true
job-passwords:
- name: ADMIN
password: 0v8ZCNaHwq1hcx+sHwRLdg9424uBh4Pin0zO4sBIb+U=