Jenkins

Parny | Jenkins Integration Guide

Parny supports direct integration with Jenkins alerts. Jenkins is a network and system monitoring tool that can create alarms to detect and prevent potential problems. This documentation explains how to redirect alarms created in Jenkins to a webhook using Parny.


Parny Settings


  1. Go to the Parny interface.

  2. Navigate to the "Services" section of your organization.

  3. Click on the "New Services" option in the upper right corner.

  4. Enter the relevant service name.

Service Name Usage: The service name here is independent of the structure and can be chosen according to the preferences of the organization.


  1. Select Jenkins from the list of integrations.

  2. Click "Add".

  3. After the service is created, the following screen will appear.


drawing


  • You can now click on the token section of your service and copy your Jenkins Webhook URL.


Prerequisites


Before proceeding with the integration, ensure that the following requirements are met:


  • Access to a Jenkins instance

  • Access to a Parny account with a jenkins endpoint configured

  • The Jenkins Pipeline plugin installed


Jenkins Configuration


To integrate Jenkins pipelines with Parny, follow these steps:


  1. Open your Jenkins instance and navigate to the pipeline you wish to integrate with Parny.


  2. Click on the "Configure" option for the pipeline.


  3. Scroll down to the "Pipeline" section and click on the "Script" option.


  4. Add the following script to the pipeline script:


import java.util.Date

Date currentDate = new Date()

pipeline {
  agent any

  stages {
    stage('Build') {
      steps {
        // Your build steps here
      }
    }
  }

  post {
    failure {
      script {
        // You can customize these values, this is simply what we suggested.
        def payload = """
        {
            "alert_name": "${env.JOB_NAME}",
            "alert_service": "Jenkins",
            "alert_date": "${currentDate}",
            "alert_description": "${env.JOB_NAME} job has failed.",
            "alert_severity": "high",
            "alert_instance": "Build Number: ${env.BUILD_NUMBER}"
        }
        """

        def url = "${PARNY_JENKINS_API_URL}"
        sh "curl -X POST -H 'Content-Type: application/json' -d '${payload}' ${url}"
      }
    }
  }
}


  1. Replace ${PARNY_JENKINS_API_URL} with the actual Parny jenkins endpoint URL.


  2. Save the pipeline configuration and run a build to test the integration.


Conclusion

By following these steps, you have successfully integrated Jenkins pipelines with Parny. You can now receive alerts whenever a pipeline fails in any steps, allowing for quick incident resolution.