Configure Single Pipeline for Multiple Webhook Events Help Documentation
The Opsera Pipeline supports webhook based start events for GitLab, GitHub, Bitbucket and Azure. 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.
Note: When a pipeline is running and user makes a commit, the pipeline will finish its current run and only IF the run was successful, it will run a second time. If the user makes multiple commits during a run, the pipeline will always use the latest commit for the next run. The pipeline will only run once after the current run no matter how many run requests it gets for that time period.
Source Repository Pipeline Step Configuration
1. In the pipeline Workflow, in Start of Workflow box, open up the Source Repository settings by selecting the gear icon(⚙︎). This will open Source Repository configurations.
2. To restrict a Pipeline based webhook trigger to a particular project and branch (master or non-master) select a source repository management Platform from the drop down. Choose from GitLab, GitHub, Bitbucket or Azure Devops.
3. Upon selecting a Platform, 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.
4. 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.
5. Enable ‘Trigger Active’ toggle to proceed with webhook registration.
6. Complete webhook registration by copying the webhook URL shown. In your SCM account’s webhook settings, paste the copied webhook URL.
Webhook Registration in SCM
Webhook configuration is specific to the Source Code Manager being used. Use the following instructions depending on which SCM you’ve configured in the Source Repository step of your pipeline.
GitLab
GitHub
Webhook Settings - By default, ‘Content type’ is set to ‘application/x-www-form-urlencoded’.
In order for a Github webhook to trigger, it must be changed to ‘application/json’. This will ensure it matches the Source Repository Settings.
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.
Bitbucket
Azure DevOps
Note: If a secondary branch is selected in Source Repository, you must repeat the following steps and select the specific branch in Azure Webhooks
Pipeline Orchestration and Queuing
Opsera Pipelines support queuing of runs when the pipeline is currently in progress. 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 NEXT as a Queued Request. Once the current run is successful, the pipeline will run a second time. The queued run will ONLY run a second time if the prior pipeline is successful, and the latest commit will always be used. If prior pipeline fails the queued request will not run.
The following will display in the Pipeline Activity Log when a pipeline has been triggered as the result of a webhook event:
Pipeline Logs
Pipeline Queuing
The following will display in the Pipeline Activity Log when a pipeline is already running and has been triggered by a webhook Event:
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 # | Registered Webhook event | git event: repo: refs_changed | A webhook repo:refs_changed event has been detected for branch: [branch name]. Opsera Automation has queued a restart of this piepline because of this event. The pipeline will start over after run count [current run]completes successfully. | Queued |
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.
Cancelling a queued request
To cancel a queued request, click on the grey ‘Queued Request’ button.
2. The following pop up will appear:
3. Click ‘Cancel Queue Request’ button. This will clear the pending run request and end the pipeline after the current run.