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.
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:
- Click Open Blue Ocean on the sidebar (as shown in the preceding screenshot).
- Click Create a new Pipeline (this will only display if there are no existing pipelines).
- Click the GitHub tile when prompted for your desired source control server.
- Authenticate with GitHub if needed and select your GitHub Organization if prompted.
- When prompted, enter the name of the GitHub repository you created earlier.
- 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 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.