Skip to end of metadata
Go to start of metadata

Pipeline is a plugin for Jenkins, based on the Groovy programming language, for managing your Continuous Deployment process. Pipeline lets you enable jobs using a Pipeline DSL (domain-specific language). You can use the Sauce Labs Jenkins plugin in conjunction with Pipeline to pass your Sauce Labs authentication credentials to Jenkins, and manage the starting and stopping of Sauce Connect.

Creating the Sauce Block Snippet

The {sauce} block lets you pass your Sauce Labs username and access key as environment variables to Jenkins.

  1. Enable the Snippet Generator in Jenkins Pipeline. 
  2. Select sauce: Sauce and Generate Groovy. 
    You will then see a block that you can add to your Groovy script. 

Creating the Sauce Connect Block Snippet

The {sauceconnect} block lets you manage starting and stopping Sauce Connect. It must be wrapped with the {sauce} block that passes your authentication credentials to Jenkins.

  1. Enable the Snippet Generator in Jenkins Pipeline. 
  2. Select sauce: Sauce Connect and Generate Groovy. 
    You will then see a block that you can add to your Groovy script  within the {sauce} block. 
  3. The hashed key in the code block below is generated when you create a Sauce Labs credential in Jenkins from the Credentials dialog

Sample Sauce and Sauce Connect Block Snippets
node('mac') {
    sauce('36987f5a-62da-40ac-bbc0-583806f9df4d') {
        sauceconnect(useGeneratedTunnelIdentifier: true, verboseLogging: true) {
            sh 'env | sort'
        }
    }
} 

Creating the Sauce Publisher/Reporting Snippet

The {saucePublisher} function lets you enable reporting between this jenkins job and sauce labs. See Setting Up Reporting between Sauce Labs and Jenkins for more details

  1. Enable the Snippet Generator in Jenkins Pipeline. 
  2. Select saucePublisher: Run Sauce Labs Test Publisher and Generate Groovy. 
    You will then see a block that you can add to your Groovy script.

Sauce Block Snippet Warning

The Publisher doesn't need to be wrapped on a Sauce Block Snippet but the Snippet does need to be present in some part of the Pipeline file in order for the Publisher to pull the correct test results.

  • No labels