The following guide helps you get up and running with our plugin for Jenkins CI:
What You'll Need
- Access the IP range
ondemand.saucelabs.comfrom your Jenkins server
- You may need to refer to the Jenkins documentation for assistance setting up a proxy
Important Steps for All Continuous Integration Configurations
When you are configuring your continuous integration platform to work with Sauce, always make sure to follow these steps:
- Update tests to reference the environment variables set by the plugin. See the topic on Setting Environment Variables for more information.
- Output the Sauce session ID to the standard output (
stdout) to allow the Sauce plugin to associate test results to Sauce Jobs. See the topic on Outputting Session IDs to stdout for more information.
Installing the OnDemand Plugin
You can install the Sauce OnDemand plugin for Jenkins though the Jenkins Administration page.
- In Jenkins, go to the Administration page
- Click Manage Jenkins
- Click Manage Plugins
- Click the Available tab
- In the list of plugins, find and select Sauce OnDemand Plugin
- Click Download now and install after restart
- In the plugin installation dialog, select Restart Jenkins when installation is complete and no jobs are running
The plugin file is fairly large, so download may take several minutes.
Configuring Sauce Labs Credentials
The Jenkins plugin provides an interface for storing your Sauce Labs authentication credentials as environment variables on the Jenkins server, one of our best practices for testing with Sauce. This allows you to reference your credentials without having to hardcode them into your tests. Because the plugin manages authentication at the global level, you can have multiple jobs running at the same time using these credentials.
- After the plugin has installed and Jenkins has restarted, go to the Administration page in Jenkins
You can click an existing domain or click Add domain
- Once in your domain of choice, click Add Credentials
- Under Kind, select Sauce Labs
- Enter the Username and API Access Key for your Sauce account
- Click OK to save
Your credentials are now saved, and you can now use them on a per-project basis. To do so:
- Go to the Administration page for one of your projects
- Click Configure
Under Sauce Labs Options, you will see the credentials you have stored as options under Credentials
Setting Authentication Environment Variables in Your Tests
Once you've set up your authentication credentials as environment variables, you can refer to them in your tests like this:
See Setting Desired Capabilities for Jenkins Projects for more information on using environment variables.
Versions Before 1.147
In versions of the plugin prior to 1.147, credential management is handled slightly differently. You will find credential management in the Manage Jenkins > Configure System section:
- Once the plugin is installed and Jenkins restarted, go to the Administration page in Jenkins
Click Manage Jenkins > Configure System
- Under Sauce Support, enter the Username and API Access Key for your Sauce account
You can find the complete changelog for each version of the Jenkins Plugin at GitHub: https://github.com/saucelabs/jenkins-sauce-ondemand-plugin/blob/master/CHANGELOG.md