Running a Jenkins job


The Generic REST API connector allows add an action to the automation policy for any of the REST API methods, GET, POST, PUT, PATCH, or DELETE.

This topic provides an example of creating an automation policy for running a job in Jenkins for adding or updating the storage based on an event that is generated for ES storage full. 

While creating an action, you can use an event stored in the BMC Helix Intelligent Automation database or provide an event in a JSON format. 

To add the Run a Jenkins Job action to a policy

  1. In the BMC Helix Intelligent Automation console, click Policies and the click Create Automation Policy.
  2. In the Policy Information section, enter a unique name and an optional description for the policy. 
  3. Select Manual or Automatic depending upon whether you want to execute the policy manually or automatically based on the incoming events.
  4. In the Trigger section, click Browse and perform one of the following steps to select an event:
    • From the Select Event Type tab, select an existing event type, and click Done.
    • On the Paste Event JSON tab, enter event in the JSON format, and click Done.

      {
      "Resource": "ES",
      "ResourceType": "Disk",
      "Alarm": "on"
      }
  5. In the Trigger Condition text box, build the following expression to match the trigger condition to the event:

    $.event.Resource == 'ES' && $.event.ResourceType == 'Disk' && $.event.Alrm == 'on'
  6. To add system or custom tags to the policy, perform the following steps:
    1. System tags: Select one or more tags from the list of available system tags. 
      Based on the event, some system tags are displayed.
    2. Custom tags: In the Tags (Optional) section, enter a key-value pair. 
      Tag key should start with an alphabet and end with an alphanumeric character. Key supports alphanumeric characters and periods, dashes, and underscores. 
  7. To add Configure action to the policy, click Add Action and perform the following steps by using the action wizard:
    1. From the Pick an automation tool section, click the connector name.
      Only configured connectors are displayed here. 
      Policy page_generic REST connector.png
    2. Click Select against Generic REST Action.
      The action name is displayed. 
      image (8).png
    3. From the HTTP Method list, select POST.
    4. In the API Path, provide the path for the job that you want to execute when the event matches the trigger condition in the policy.
      For example, <host:port>/view/IA-Jenkin-Actions/job/IA-ES-MinFreeSpace-Alarm-Action/buildWithParameters.
    5. (Optional)To define variables and use them for dynamically configuring the API path, and use the same action for multiple API endpoints based on incoming events. In the Query params section, provide the following values for each of the parameters.

      Field

      Value

      Type

      Specify the type as Query.Valid values: Query, Path, Header, Cookie

      Key

      Specify the key as Token.

      Value

      Provide the value that matches the key.

      Use the following expressions to transform variable values at runtime that you defined while creating the policy.
       

      "key": $.'Set Input Variables'.output.VARIABLE_NAME
      fn:concat(http/||$.event.msg||$.event.splitTest||More Concat)
    6. (Optional) If you want to specify a request body and edit it, perform the following steps:
      1. Select the Content type as JSON.
      2. To transform the JSON by using the Raw JSON editor, do the following:
        1. In the Raw JSON editor, paste the JSON payload you want to edit.
          You can add, delete and modify the JSON fields in this editor by using the event slots and variables that you define during policy creation.
      3. To transform the JSON by using the JSON editor, do the following:
        1. Hover your mouse next to the field you want to transform.
        2. Click 1750337031405-909.png.
          You can transform the JSON fields in the editor by using the event slots and predefined variables populated automatically in the variable list.
          After you add a transformation, a green check mark appears next to the field. The JSON editor updates automatically because both these editors are dynamically synced.
          1. Click Done.
            The added action appears in the Action Configuration section on the Create Automation Policies page.

       Advance JSON editor.png

  1. In the Estimated Savings section, enter an approximate time (in minutes) and money (in USD) that you may save by automating this action.
  2. Select Publish Policy and click Save to publish the policy.
    This policy runs every time an event that matches the trigger conditions appears in BMC Helix Intelligent Automation. 

 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*