Newer Version Available

This content describes an older version of this product. View Latest

Configure Your Environment for Jenkins

Before integrating Salesforce DX into your existing Jenkins framework, configure your Jenkins environment.
  1. In your Dev Hub org, create a connected app as described by the JWT-based authorization flow. This step includes obtaining or creating a private key and digital certificate.
    Make note of your consumer key (sometimes called a client ID) when you save the connected app. You need the consumer key to set up your Jenkins environment. Also have available the private key file used to sign the digital certificate.
  2. On the computer that is running the Jenkins server, do the following.
    1. Download and install the Salesforce DX CLI.
    2. Store the private key file as a Jenkins Secret File using the Jenkins Admin Credentials interface. Make note of the new entry’s ID.
      You later reference this Credentials entry in your Jenkinsfile.
    3. Set the following variables in your Jenkins environment.
      • HUB_ORG_DH—The username for the Dev Hub org, such as juliet.capulet@myenvhub.com.
      • SFDC_HOST_DH—The login URL of the Salesforce instance that is hosting the Dev Hub org. The default is https://login.salesforce.com
      • CONNECTED_APP_CONSUMER_KEY_DH—The consumer key that was returned after you created a connected app in your Dev Hub org.
      • JWT_CRED_ID_DH—The credentials ID for the private key file that you stored in the Jenkins Admin Credentials interface.
      The names for these environment variables are just suggestions. You can use any name as long as you specify it in the Jenkinsfile.
  3. Set up your Salesforce DX project so that you can create a scratch org.
  4. (Optional) Install the Custom Tools Plugin into your Jenkins console, and create a custom tool that references the Salesforce CLI. The Jenkins walkthrough assumes that you created a custom tool named toolbelt in the /usr/local/bin directory, which is the directory in which the Salesforce CLI is installed.