The Opsera Pipeline supports webhook based start events for GitLab, GitHub and Bitbucket.
With this functionality user can manage what branches the trigger event will occur off of. User can select a primary and secondary branch in this form and any time a commit occurs on one of these branches, the pipeline will be triggered. This document will outline the steps needed to configure a webhook & also show how to trigger a pipeline using the webhook.
...
On the workflow configuration, Click on ‘Settings’ the gear icon from ‘Start of Workflow’ pipeline step
...
It Source Repository configuration form will open the configuration form.
...
Select a source repository management Platform from the drop down. Choose from GitLab, GitHub or Bitbucket.
Upon selecting a Platform and click on “ Register Git account “ - It will open the configuration values one by one. Select each one based on your requirement (Explanation shown in the screenshot below).
...
Click on ‘Enable Event Based Trigger’ checkbox and then click on ‘Register Webhook’ button
...
Webhook configuration will be saved in Opsera Pipeline
...
At the same time, Webhook will be automatically configured in respective SCM Tool
...
, corresponding accounts stored in the Tool Registry will be fetched and provided in the Account drop down. Select the account containing the project you wish to configure your webhook trigger events to.
Once the Account is selected, a list of Repositories and then Branches will be fetched and provided in drop downs. Select the Repository of your project and then select a Primary Branch. You have the option to select a Secondary Branch as well. Once the webhook is successfully registered in the following steps, this pipeline will be triggered any time a commit occurs on the selected Primary and Secondary Branch.
...
Webhook Registration
Enable the ‘Trigger Active’ toggle to proceed with webhook registration.
Complete webhook registration by copying the webhook URL shown. In your SCM account’s webhook settings, paste the copied webhook URL:
Bitbucket:
...
GitLab:
...
Please Note: If this method is used then this pipeline will be bound to that selected branch activity in order to be triggered. Any activity in other branches or projects for this account will be ignored.
How to trigger Webhook in pipelines
...
Opsera pipeline is triggered automatically, after a commit has been made on the SCM Tool - Branchselected Branch or Branches.
...
The same can also be verified with SCM Tool – Webhook history page – where a successful commit event trigger will be registered
...
The above steps indicate the successful configuration and trigger of Post commit Webhook.
Pipeline Orchestration and Queuing
If a pipeline is already running and another webhook request comes in, the webhook request will be logged in the Pipeline Logs as part of the current run and the pipeline run request will be queued. Once the current run is successful, the pipeline will run a second time.
The following will display when a pipeline has been triggered as the result of a webhook event:
...
Pipeline Queue:
Opsera Pipelines support queuing of runs when the pipeline is currently in progress.
If a webhook event is triggered while the pipeline is already running, the second webhook event will trigger a queue request within the same run. Even if multiple webhook events are triggered due to new commits being made on the branch during a pipeline run, there will still only be one subsequent run, and the latest commit will always be used. The following will display in the Pipeline Activity Log:
Run | Step | Action | Message | Status |
---|---|---|---|---|
current run # | queued: webhook triggered start | push hook event | ‘A webhook Push Hook event has been detected for branch: (branch name). Opsera Automation has queued a restart of this pipeline because of this event. The pipeline will start over after run count (current run #) completes successfully’ | Queuing Request |
The green ‘Repeat Once’ button will change to ‘Queued Request’
...
Note: The queued run will ONLY run if the prior pipeline is successful. If prior pipeline fails the queued request will not run.
Cancel a queued request:
To cancel a queued request, click on the grey ‘Queued Request’ button.
The following pop up will appear:
Click ‘Cancel Queue Request’ button. This will clear the pending run request and end the pipeline after the current run.