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
Configuring the Plugin to Use the European Data Center
If you are running jobs on our European data center, you have an option to use our Jenkins plugin to see all of the integrated results and reports. You can choose the data center you want to use by updating your credentials and then using those in your build configurations.
What You'll Need
- Use Sauce OnDemand Plugin version 1.182 or above in order to use the feature outlined here.
By default the Jenkins plugin will use your credentials the US data center, so you need to create a new set of credentials to use the EU data center. You should set a descriptive ID for the EU credentials to make them distinct from the US credentials, as this will make it easier to set up pipelines with the appropriate 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.
- Enter the Username and API Access Key for your Sauce account.
- Select EU as a Sauce Data Center.
Specify an ID that will be used to identify credentials within the pipelines setup.
If the ID field is left blank it will be auto-generated. If you forget or don’t know which ID is associated with the EU credentials, you can use the Pipeline Script page to generate the script with the right ID for you
- Click Save.
Non-Pipeline Build Configuration
If you are using non-pipeline builds, select the correct credentials in the Sauce Labs menu within your build.
- Go to Sauce Labs Options.
- Under Credentials, select the credentials with the (EU) suffix
- Click Save.
Pipeline Build Configuration
For pipeline builds, use the credential ID you created for the European data center, as shown in this code example.