We're here to help
Masking credentials in Jenkins
Provar now supports execution on Jenkins without needing to check the Provar .secrets file into GitHub. This is to reduce exposure of the credentials used in Test Case execution. The solution is to use Jenkins’ credentials plugin to set up the passwords and security tokens as environment variables.
- A Jenkins server
- Required privileges on Jenkins to install plugins and create a project
Download required plugins
You will need to download and install three Jenkins plugins:
- Credentials plugin: provides a centralized way to define credentials that can be used by your Jenkins instance, plugins and build jobs.
- Credentials Binding plugin: allows you to configure your build jobs to inject credentials as environment variables.
- Plain Credentials plugin: a plugin dependency required by the Credentials Binding plugin.
When all three plugins are installed, your Jenkins installation has the required directives to allow you to inject secrets into Jenkins.
Go to Jenkins (menu) and choose Credentials.
Create a new user and password credentials. Once it’s created, copy its credentials ID. This is a hash which is used by Jenkins to identify these specific credentials.
Create and configure your new build job
Create a new item (new job), name it, and select ‘Freestyle project’ or any other.
After installing the plugins, you will now have a new option under ‘Build Environment’ which is called ‘Use secret text(s) or file(s)’. Tick this option and a new box will appear: ‘Bindings’ and underneath it ‘Add’:
Click ‘Add’ and choose ‘Username and password (separated)’:
A new box will appear. Here you can enter the variable name which will hold the real username as in the credentials. You can also enter the variable name for the password which will hold the real password as in the credentials:
Provide a Build Step of ‘Invoke Ant’:
Provide the ANT build file path location:
Then save your Project.
Remove .secrets from the Provar Project.
Run your job and check console output.
Application successfully launched without having .secrets file in a Project:
And if run same project from Provar you will see error message: