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 event management to receive notifications about jobs from Jenkins projects.

Before you begin

Specific to IBM Cloud Private deployment If you are using IBM Cloud Event Management 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 Cloud Event Management 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 event management as events. The events are then correlated into incidents.

Important: The Jenkins server needs the Notification Plug-in to send the notifications.

Procedure

  1. Click Administration > Integrations.
  2. Click New integration.
  3. Go to the Jenkins tile and click Configure.
  4. Enter a name for the integration and click Copy 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.
    Tip: 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 event management.
      • 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 Cloud Event Management.