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:

  1. Run the following command:

    openssl pkcs7 -in cert.pem -out cert.crt -print_certs
    
  2. 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
    
  3. Restart your Jenkins server process to pick up the new certificate.

  4. Ensure your Jenkins server host can resolve the domain name of your Monitoring installation.
  5. 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.

Procedure

  1. Go to Administer > Monitoring > Integrations on the IBM Cloud Pak console.
  2. Click Configure an integration.
  3. Go to the Jenkins tile and click Configure.
  4. 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.
  5. Click Save.
  6. Log into your Jenkins server as administrator.
  7. Ensure that the Notification Plug-in is installed on your Jenkins server.

    Tips:

    • 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.
  8. Configure the Jenkins project you want to receive notifications from as follows:

    1. Click the project name and then click Configure.
    2. Click the Job Notifications tab, and click Add Endpoint.
    3. 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.
    4. Click Save

    5. Repeat the steps for each project you want to receive notification from.
  9. To start receiving notifications about Jenkins jobs, ensure that Enable event management from this source is set to On in Monitoring.