Job Environment Variables Status Sync

Introduction

The plugin offers a seamless integration framework for developers across various platforms, enabling them to effortlessly monitor and engage with Jenkins pipelines. This plugin facilitates external systems to: +

  • Retrieve Pipeline Task Execution Statuses: It allows for a straightforward way to access and track the status of individual pipeline tasks, providing visibility into the progress and success of each step.
  • Access Pipeline Environment Variables: Users can seamlessly access environment variables associated with pipeline runs. This feature is crucial for understanding the context and environment within which the pipeline is executing, facilitating more informed decision-making and dynamic configuration.
  • Send Custom Information During Pipeline Execution: The plugin enables the transmission of custom information from external systems directly into the pipeline execution process. This allows for dynamic integration and customization, enhancing the flexibility and adaptability of CI/CD workflows.

By adopting this plugin, platform developers can significantly enhance their continuous integration and continuous deployment (CI/CD) processes, all with minimal configuration overhead. All that's required is to specify the request URL and pertinent details within the Jenkins system settings, and the plugin seamlessly manages the communication bridge between Jenkins and external platforms, streamlining integration and collaboration.

Getting started

System Config

System Config

To begin using the plugin and integrating your external system with Jenkins pipelines, follow these steps:

  1. Navigate to Jenkins System Configuration Go to Manage Jenkins > Configure System. Scroll down to the section for Job Status Notification Config.
  2. Configure the Request Information You'll need to provide the following details:
  • Request URL:

    • Enter the endpoint where the plugin should send pipeline execution data. This could be a REST API or another system endpoint designed to receive updates from Jenkins pipelines.
    • Example: http://api.example.com/pipeline/status
  • Request Method:

    • Select the HTTP method that the plugin will use to communicate with your external system.
    • Available options:
      • GET – Retrieve data.
      • POST – Send data to the external system (most common).
      • PUT – Update existing data on the external system.
      • DELETE – Remove data on the external system.
    • Choose the method that best suits your API or integration requirement.
  • Headers (Optional):

    • If the external system requires specific headers for authentication (e.g., API tokens) or other metadata, add the required headers here.
    • To add a header:
      • Enter the Header Key (e.g., Authorization).
      • Enter the Header Value (e.g., Bearer YOUR_API_TOKEN).
  1. Save the Configuration After filling out the request URL, method, and headers, click Save at the bottom of the page.
  2. Plugin in Action During the execution of a Jenkins pipeline, the plugin will automatically send real-time status updates and environment variables to the configured endpoint. The system will use the provided HTTP method and include the specified headers in each request.

Sending Notifications

Notify Config To send notifications during pipeline execution, simply include the required information in the body of the request. The plugin will handle the rest and send the data to the configured endpoint.

  • Body Content: The information you want to send, such as pipeline status, task details, or custom data.
  • The request will automatically use the configured URL, method, and headers. No complex setup required—just add your information to the body and the plugin will send it as part of the notification!

Sample request

The pipeline starts to execute POST request The fields of buildNo , jobExecuteStatus and body are added by the plugin, and the others are environment variables, and build with parameter will also be in the environment variables jobExecuteStatus has the following parameters:

  • START
  • RUNNING
  • COMPLETE
  • SUCCESS
  • UNSTABLE
  • FAILURE
  • NOT_BUILT
  • ABORTED
{
  "buildNo": "3",
  "jobExecuteStatus": "RUNNING",
  "body":"ssh executed !",
  "BUILD_DISPLAY_NAME": "#3",
  "BUILD_ID": "3",
  "BUILD_NUMBER": "3",
  "BUILD_TAG": "jenkins-test-folder-openssh9-test-3",
  "BUILD_URL": "http://api.example.com:39931/job/test-folder/job/openssh9-test/3/",
  "CI": "true",
  "CLASSPATH": "",
  "COPY_REFERENCE_FILE_LOG": "/var/jenkins_home/copy_reference_file.log",
  "DSO_URL_PATH": "http://api.example.com:32553/",
  "EXECUTOR_NUMBER": "-1",
  "HOME": "/root",
  "HOSTNAME": "jenkins-service-5ccc5794f4-8cjr4",
  "HUDSON_HOME": "/var/jenkins_home",
  "HUDSON_SERVER_COOKIE": "c5e3ffff68935f12",
  "HUDSON_URL": "http://api.example.com:39931/",
  "JAVA_HOME": "/opt/java/openjdk",
  "JENKINS_HOME": "/var/jenkins_home",
  "JENKINS_INCREMENTALS_REPO_MIRROR": "https://repo.jenkins-ci.org/incrementals",
  "JENKINS_PORT": "tcp://127.0.0.1:50000",
  "JENKINS_PORT_50000_TCP": "tcp://127.0.0.1:50000",
  "JENKINS_PORT_50000_TCP_ADDR": "127.0.0.1",
  "JENKINS_PORT_50000_TCP_PORT": "50000",
  "JENKINS_PORT_50000_TCP_PROTO": "tcp",
  "JENKINS_PORT_8080_TCP": "tcp://127.0.0.1:8080",
  "JENKINS_PORT_8080_TCP_ADDR": "127.0.0.1",
  "JENKINS_PORT_8080_TCP_PORT": "8080",
  "JENKINS_PORT_8080_TCP_PROTO": "tcp",
  "JENKINS_SERVER_COOKIE": "c5e3ffff68935f12",
  "JENKINS_SERVICE_HOST": "127.0.0.1",
  "JENKINS_SERVICE_NODE_PORT": "tcp://127.0.0.1:8080",
  "JENKINS_SERVICE_NODE_PORT_50000_TCP": "tcp://127.0.0.1:50000",
  "JENKINS_SERVICE_NODE_PORT_50000_TCP_ADDR": "127.0.0.1",
  "JENKINS_SERVICE_NODE_PORT_50000_TCP_PORT": "50000",
  "JENKINS_SERVICE_NODE_PORT_50000_TCP_PROTO": "tcp",
  "JENKINS_SERVICE_NODE_PORT_8080_TCP": "tcp://127.0.0.1:8080",
  "JENKINS_SERVICE_NODE_PORT_8080_TCP_ADDR": "127.0.0.1",
  "JENKINS_SERVICE_NODE_PORT_8080_TCP_PORT": "8080",
  "JENKINS_SERVICE_NODE_PORT_8080_TCP_PROTO": "tcp",
  "JENKINS_SERVICE_NODE_SERVICE_HOST": "127.0.0.1",
  "JENKINS_SERVICE_NODE_SERVICE_PORT": "8080",
  "JENKINS_SERVICE_NODE_SERVICE_PORT_JENKINS_SERVICE_NODE_50000": "50000",
  "JENKINS_SERVICE_NODE_SERVICE_PORT_JENKINS_SERVICE_NODE_8080": "8080",
  "JENKINS_SERVICE_PORT": "50000",
  "JENKINS_SERVICE_PORT_JENKINS_50000": "50000",
  "JENKINS_SERVICE_PORT_JENKINS_8080": "8080",
  "JENKINS_SLAVE_AGENT_PORT": "50000",
  "JENKINS_UC": "https://updates.jenkins.io",
  "JENKINS_UC_EXPERIMENTAL": "https://updates.jenkins.io/experimental",
  "JENKINS_URL": "http://api.example.com:39931/",
  "JENKINS_VERSION": "2.469",
  "JOB_BASE_NAME": "openssh9-test",
  "JOB_DISPLAY_URL": "http://api.example.com:39931/job/test-folder/job/openssh9-test/display/redirect",
  "JOB_EXECUTE_STATUS": "RUNNING",
  "JOB_NAME": "test-folder/openssh9-test",
  "JOB_URL": "http://api.example.com:39931/job/test-folder/job/openssh9-test/",
  "KUBERNETES_PORT": "tcp://127.0.0.1:443",
  "KUBERNETES_PORT_443_TCP": "tcp://127.0.0.1:443",
  "KUBERNETES_PORT_443_TCP_ADDR": "127.0.0.1",
  "KUBERNETES_PORT_443_TCP_PORT": "443",
  "KUBERNETES_PORT_443_TCP_PROTO": "tcp",
  "KUBERNETES_SERVICE_HOST": "127.0.0.1",
  "KUBERNETES_SERVICE_PORT": "443",
  "KUBERNETES_SERVICE_PORT_HTTPS": "443",
  "LANG": "C.UTF-8",
  "NODE_LABELS": "built-in master",
  "NODE_NAME": "built-in",
  "PATH": "/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "PWD": "/",
  "REF": "/usr/share/jenkins/ref",
  "RUN_ARTIFACTS_DISPLAY_URL": "http://api.example.com:39931/job/test-folder/job/openssh9-test/3/display/redirect?page=artifacts",
  "RUN_CHANGES_DISPLAY_URL": "http://api.example.com:39931/job/test-folder/job/openssh9-test/3/display/redirect?page=changes",
  "RUN_DISPLAY_URL": "http://api.example.com:39931/job/test-folder/job/openssh9-test/3/display/redirect",
  "RUN_TESTS_DISPLAY_URL": "http://api.example.com:39931/job/test-folder/job/openssh9-test/3/display/redirect?page=tests",
  "SHLVL": "0"
}

LICENSE

Licensed under MIT, see LICENSE