Configuring webhook triggers in Jenkins for a freestyle job or pipeline job

Configure webhook triggers in Jenkins for a freestyle job or pipeline job.

Configuring webhook triggers in Jenkins
  1. Create a freestyle job or pipeline job in Jenkins with the HCL VersionVault plug-in.
  2. Open the job configuration and go to the Build Triggers section, and then select the Generic Webhook trigger check box.
  3. In the Post content parameters section:
    1. In the Variable subsection, enter a variable called payload.
    2. In the Expression subsection, enter the symbol $ and then select the JSONPath option.
    3. Scroll down and click Add.
    4. In the Variable subsection, create a new variable creation entity called ACTION.
    5. In the Expression subsection, enter the value $.action and then select the JSONPath option.
  4. In the Token field, enter a simple string of printing characters. This value is used for creating a trigger script in step 4 of Create trigger scripts in HCL VersionVault.
  5. Click Save to save your changes.

Optional: After completing Configuring webhook triggers in Jenkins

  1. Return to the Jenkins Dashboard.
  2. Go to the Manage Jenkins section and click Configure system.
  3. Search for the Generic Webhook Trigger section, and then select the Whitelist enabled check box, and click Add.
  4. Select the Verify with HMAC check box.
    Note: Do not enter a value in the IP, CIDR or IP range field.
  5. In the HMAC Header subsection, enter X-VV-Signature. At first, you must set up a new secret credential, otherwise proceed to step 9.
  6. In the HMAC Secret subsection, click Add and select Jenkins.
  7. From the Kind drop-down, select the Secret text value.
  8. Enter a new Secret value and the ID for it, and then click Add.
  9. Select the new credential ID created for HMAC Secret. Enter HmacSHA256 in the HMAC Algorithm field.
  10. Click Save to save your changes.
Note: Using a secret credential to sign the payload is a good way to protect Jenkins from rogue request senders.

Create trigger scripts in HCL VersionVault

  1. Download a copy of the Perl script sample available in your Jenkins job settings.
  2. Click the Sample Jenkinsfiles and scripts for Pipeline builds option to see the sample.
  3. Edit the following variables in the Perl script:
  4. Install the trigger script in a file location where the VersionVault clients can access it (as you might do for any trigger script). Ensure that the Perl script has the correct permissions to be executed.
Deliver complete trigger script
When a delivery from a stream is completed into the target stream of the VOB where the trigger script is created, the trigger is fired, and a new build of the target stream is started in the configured Jenkins job.
  1. Go to the relevant target stream view.
    cleartool setview integrationview
    Note: You need to create the trigger script logged in as the VOB owner.
  2. Create the trigger script. Run the mktrtype command with the correct syntax arguments depending on the operating system for which the trigger will be created. For more information, see the following UNIX and Windows® examples:
    Notes: Adjust the following flags as per your requirement. For more information about the mktrtype command, see mktrtype.
    • The -nc flag means no comments.
    • The -print flag prints trigger execution output.
    • The -postop deliver_complete flag indicates that the trigger is fired after a deliver completion.
    • The -execunix or -execwin flag is used to run a command or script in the right system at trigger firing.
    • UNIX example:
      cleartool mktrtype -nc -ucmobject -all -print -postop deliver_complete -execunix “full path to/perl script.pl" trigger name@VOB tag
    • Windows example:
      cleartool mktrtype -nc -ucmobject -all -print -postop deliver_complete -execwin “full path to/perl script.pl" trigger name@VOB tag
  3. Ensure the target stream is set up in the Jenkins job settings. For more information, see Configuring the plug-in for a freestyle job for the HCL VersionVault-Jenkins integration or Configuring the plug-in for a pipeline job for the HCL VersionVault-Jenkins integration.
  4. Test the trigger by doing a delivery to the target stream and verifying the newly generated build of the stream in Jenkins.