Installing, configuring, and testing a Jenkins CI server

Setting up a Jenkins server is a broad topic beyond the scope of this chapter. A good way, however, to get started on your local computer is to go to http://jenkins-ci.org/ and download one of the prebuilt installations for your operating system.

In this case, I used the Mac pkg file download. Select the most common plugins during the installation process, as this includes the Pipeline feature and Groovy programming language integration previously described. After installation, I was able to navigate to http://localhost:8080 to find Jenkins waiting for me, as shown here:

Jenkins has a plugin system that permits many custom extensions to its base functionality, by clicking on Manage Jenkins and then Manage Plugins. Install the following plugins:

  • Blue Ocean provides the pipeline UI shown in the previous section.
  • Custom Tool allows you to integrate the Salesforce DX CLI.
  • Node.js allows you to run npm and other commands from Jenkinsfiles.

Since you already have a Jenkinsfile in the repository you created earlier, the process to actually create a working pipeline is quite straightforward as Jenkins will auto detect the file and create the necessary jobs to run your pipeline.

Even though much of the configuration is encapsulated in the Jenkinsfile, there is still some further configuration to be performed that is not covered in this book. This configuration is done at a server level so that it is shared by other pipelines. It includes ensuring that Jenkins knows where the SFDX CLI is installed and how to authenticate with it through a private certificate. You can review detailed documentation about Jenkins and other CI servers here: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ci.htm. You must perform this setup before following the steps that follow. Or, if you prefer, just follow along!

The following steps cover the overall process of adding an existing repository to Jenkins through the Blue Ocean user interface. This is an optional user interface for setting up pipelines, but is much easier to use than the traditional Jenkins management UI:

  1. Click Open Blue Ocean on the sidebar (as shown in the preceding screenshot).
  2. Click Create a new Pipeline (this will only display if there are no existing pipelines).
  3. Click the GitHub tile when prompted for your desired source control server.
  4. Authenticate with GitHub if needed and select your GitHub Organization if prompted.
  5. When prompted, enter the name of the GitHub repository you created earlier.
  6. Click Create Pipeline.

Once the pipeline is created, Jenkins will automatically start to execute it for the first time:

The preceding screenshot shows Jenkins automatically running a pipeline.

If you see errors, carefully review the documentation linked previously to make sure you have not missed any server setup steps. In addition to the documented steps, I found that I did need to ensure that I had the SFDX_USE_GENERIC_UNIX_KEYCHAIN environment variable defined under Manage Jenkins | Configure System | Environment Variables. Do not forget to configure the Node.js plugin once installed. You may also see some security approvals to accept. These can be viewed on the Manage Jenkins page.

If you click on the row of the build itself as it is running, you can monitor the output of the commands in real time, just as if you had run them manually:

Jenkins has many ways to detect whether future builds are required by monitoring for changes in the associated source control system. These can be found by navigating to the build configuration. From the main Jenkins home page, find your repository in the dashboard view and hover your mouse pointer over it to access the drop-down menu and select the Configure page. In the Scan Repository Triggers section of the configuration page, set the interval to 1 minute. Not that you would not normally do this in practice; this is just to explore further in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.145.158