Configuring Jenkins as an event source
Jenkins helps automate software development processes such as builds to allow continuous integration. You can set up an integration with Monitoring to receive notifications about jobs from Jenkins projects. The Jenkins integration is only available in Monitoring, Advanced.
Before you begin
If you are using Monitoring in an IBM Cloud Private environment, your CA certificate might need to be an X.509 certificate. Complete these steps to convert your PEM certificate:
Run the following command:
openssl pkcs7 -in cert.pem -out cert.crt -print_certs
Import your certificate to the JVM keystore as a trusted certificate:
keytool -storepass <store_password> -import -noprompt -trustcacerts -alias <certificate_alias> -keystore cacerts -file cert.crt
Restart your Jenkins server process to pick up the new certificate.
- Ensure your Jenkins server host can resolve the domain name of your Monitoring installation.
- Modify the DNS server or add the host and domain name to the hosts file.
About this task
Notifications can be sent for single job stages or all stages of a job. Configure each project separately from which you want to receive notifications. The notifications are raised in Monitoring as events. The events are then correlated into incidents.
Important: The Jenkins server needs the Notification Plug-in to send the notifications.
- Go to Administer > Monitoring > Integrations on the IBM Cloud Pak console.
- Click Configure an integration.
- Go to the Jenkins tile and click Configure.
- Enter a name for the integration and click Copy to add the generated webhook URL to the clipboard. Ensure you save the generated webhook to make it available later in the configuration process. For example, you can save it to a file.
- Click Save.
- Log into your Jenkins server as administrator.
Ensure that the Notification Plug-in is installed on your Jenkins server.
- Check first whether the plug-in is installed by clicking Jenkins > Manage Jenkins > Manage Plugins.
- Go to the Installed tab and look for the Notification plugin.
- If not in the list of installed plug-ins, go to the Available tab and search for Notification plugin.
- Select the check box for the plug-in and click Install.
Configure the Jenkins project you want to receive notifications from as follows:
- Click the project name and then click Configure.
- Click the Job Notifications tab, and click Add Endpoint.
Set up the connection as follows:
- Select JSON from the Format list.
- Select HTTP from the Protocol list.
- Select when you want to receive notifications about the job from the Event list. For example, All Events sends a notification for each job phase, while Job Finalized only triggers a notification when the job has completed, including post-build activities. Select All Events to receive detailed information about the jobs.
- Paste the webhook URL into the URL field. This is the generated URL provided by Monitoring.
- Enter 5 in the Log field. This determines the number of lines to include from the log in the message.
- Repeat the steps for each project you want to receive notification from.
To start receiving notifications about Jenkins jobs, ensure that Enable event management from this source is set to On in Monitoring.