Jenkins Integration (via MS Power Automate)

Last modified on 2023/03/27 10:45

IntegrationIntroduction

You can integrate third-party systems with Service Manager in many ways. The method you select will depend on business requirements, architectural and security constraints as well as the characteristics specific to each third-party application or service.

This document describes an integration process that has already been implemented in a customer context. 

To find out more about this integration (e.g. scripts to be used), please do not hesitate to contact your EasyVista contact, or your service provider and integrator.

Overview of the integration

Jenkins is an open source automation server. It helps automate the parts of software development related to building, testing, deploying and facilitating continuous integration and continuous delivery.

This integration enables you to start or stop a Jenkins job via Microsoft Power Automate when modifying the management method of a configuration item (CI) in the Service Catalog (Is a service option selected or unselected in the CI form).
 

Use case: Start a development platform or an Amazon platform when the Is a service option is selected in the CI form.
 

Preview of the tools used in this integration

IntegrationTool_MicrosoftAzureLogicApps
  • Microsoft Azure Logic Apps: It enables you to create logic apps that run workflows and provide access to cloud data and services using ready-to-use connectors.
IntegrationTool_MicrosoftPowerAutomate
  • Microsoft Power Automate (formerly known as Microsoft Flow): It enables you to automate recurrent tasks by building workflows using Web applications. The tool relies on standard connectors based on Microsoft Azure Logic Apps for interfacing with any endpoint via HTTP/HTTPS. It can also use the Microsoft Graph gateway via the Microsoft Graph API.
Integration Data Feed (direction) Authentication Type Integration Connector Options

Favicon EasyVista - 32.png Service Manager

Down arrow.png

Logo Icon - Microsoft Flow.png

Down arrow.png

Logo - Jenkins.png

  • Depending on the third-party service used (authentication managed by Logic Apps)
  • Basic Authentication for the Service Manager API REST
  • Service Manager :

    EV Integration connector icon - Workflow.png    Workflow

    EV Integration connector icon - Business rule.png    Business rule

  • MS Power Automate:

    EV Integration connector icon - Receive.png    Connector: When a HTTP request is received

    (Trigger Service Manager => Logic Apps)

Available versions
SaaS On-premises
Service Manager Check icon.png Check icon.png
Third-party product Check icon.png N/A

Jenkins - definitions

  • Jenkins is an open-source automation tool for continuous integration.
  • Each time software code is modified in the configuration management, Jenkins will perform a series of tasks to automatically recompile and test the software and send an alert to developers in the event of errors.
  • A job is a set of tasks that Jenkins must perform in a sequence, e.g. extract the source code from the version control, compile the code, run individual tests, etc.
  • A build represents the execution of all of the job's tasks.

Flows

Data feed diagram - EN.png

Prerequisites

  • You must add the fields specific to the Jenkins integration in the Create a new Configuration Item wizard  - Open url.png See Procédure
  • You must add the Start Jenkins Flow field to the CI form in Service Manager  - Open url.png SeeProcédure

Caution

Caution_TitleActionInPowerAutomateFlow
  • When you create workflow actions in Microsoft Power Automate, you must rename them as indicated in the procedure. This is because certain items of information in the name refer to the title of the action. If you do not respect the naming convention, the workflow will not be triggered correctly.

example  The split(body('Analyze_Ticket_Info')'')?['AVAILABLE_FIELD_6'],',') instruction refers to the action called Analyze Ticket Info

Note: Spaces in the title will automatically be replaced by the underscore _.

Step-by-Step Integration Process

You configure the running of a Jenkins job in Service Manager, via Microsoft Power Automate in two phases:

Microsoft Azure Logic Apps: Create the MS Power Automate flow

Description of the workflow

Azure flow description.png
  • Step 1 : Create the step that will trigger the flow
  • Step 2 : Start the Jenkins flow
  • Step 3 : Save the configuration of the workflow


Step 1: Create the step that will trigger the flow

==> The flow is triggered when the management method of a configuration item (CI) in the Service Catalog is modified, i.e. when the Service Manager ( Is a service option is selected or unselected in the CI form).

1. Log in to the Azure portal using your Azure account.

2. Create a new logic app. Open the Logic App Designer.
      Open url.png See Microsoft Azure Logic Apps integration for details on the procedure

3. Create a When a HTTP request is received step that will trigger the workflow.

Microsoft Power Automate - Trigger - When a http request is received.png
  • Specify the information on the trigger.
    • Body: Copy and paste the JSON schema below.

      Display the JSON schema

      {
         "type": "object",
         "properties": {
             "URL": {
                 "type": "string"
              },
             "Account": {
                 "type": "string"
              },
             "ID": {
                 "type": "string"
              },
             "Service": {
                 "type": "string"
              },
             "Flow": {
                 "type": "string"
              }
          }
      }
    • Method: Select the POST value.
  • Save the trigger.

    The following information will be retrieved from Service Manager: URL, Account, CI ID, Service boolean value indicating the management method of the CI in the Service Catalog (0 = CI not managed in the catalog, 1 = CI managed in the catalog), Flow boolean value indicating the state of the Start Jenkins Flow checkbox in the CI form (0 = box is not checked, 1 = box is checked)


Step 2: Start the Jenkins flow

          Flow - Condition Yes.png

1. Create a Condition action to check for changes to the state of the Start Jenkins Flow checkbox in the CI form.

Flow - Condition Run flow - Line condition.png
  • Rename it Condition using Browse black points icon.png in the title bar.
  • Click Add to add the following line to the condition.
Value tested Condition line
State of the Start Jenkins Flow checkbox in the CI form
  • Select Value: Select the Flow field to return the state of the checkbox.
  • Comparator: Select is equal to.
  • Value: Enter True.

2. Specify the actions to be performed when the Start Jenkins Flow checkbox is selected (value True - condition satisfied).

  • Go to the If Yes branch.
  • Select Add an action to add the following actions.

3. Create a HTTP action to start the Jenkins flow.

Microsoft Power Automate - Action - HTTP Post.png
  • Rename it HTTP Send To Jenkins Jobs using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Method: Enter the POST value.
    • URI: Enter the full URL of the Jenkins job in the following format.
      https://{Jenkins_server}/view/{Job_folder}/job/{Job_name}/

Replace:

  • {Jenkins_server} with the URL of your Jenkins server
  • {Job_folder} with the folder where your Jenkins jobs are saved
  • {Job_name} with the name of the Jenkins job to be created
example   
https://Jenkins.net/view/Dev/job/Start_environment/


Step 3: Save the configuration of the workflow

1. Click Save at the bottom of the flow.

          Azure flow - Save configuration.png

Service Manager: Start and stop the Jenkins flow

Step 1: Add the information specific to the Jenkins integration

Note: The information specific to the Jenkins integration may not appear in the CI form or in the Create a new Configuration Item wizard. If this is the case, you must add it manually.

1. Add the fields specific to the Jenkins integration in the Create a new Configuration Item wizard based on your requirements.

     Open url.png See the detailed procedure

Note: The fields specific to the Jenkins integration can be found in the AM_ASSET table. These fields, JENKINS_FIELD_1 to JENKINS_FIELD_6, are available fields.

2. Add the Start Jenkins Flow field to the CI form.

     Open url.png See the detailed procedure

Note: The field can be found in the AM_ASSET table. It is called START_JENKINS_FLOW.

Step 2: Start and stop the Jenkins flow from the CI form

          CI form.png

1. Select the Start Jenkins Flow checkbox in the CI form to enable the Jenkins flow. (1)

2. Select the Is a service option in the CI form to monitor the CI in the Service Catalog. (2)

or

Unselect the Is a service option in the CI form if you do not want to monitor the CI in the Service Catalog.

3. Click Save.

The Jenkins flow will automatically start or stop.

Links to other integrations

Tags:
Powered by XWiki © EasyVista 2022