In this lab we will explore the CloudBees CI Cross Team Collaboration feature. Cross Team Collaboration simplifies the cumbersome and complicated tasks of triggering downstream jobs by eliminating the need to identify and maintain the full path for every downstream job. Simply put, this proprietary CloudBees CI feature connects pipelines, increasing automation and collaboration. Prior to this feature, the details of every downstream job (Jenkins instance ID, full job name, Git branch name) all had to be meticulously specified in the upstream job. If the job name changed, the upstream job had to be refactored, creating a maintenance burden and discouraging the adoption of event-based triggers.
The Cross Team Collaboration feature is designed to greatly improve team collaboration by connecting team Pipelines across any number of CloudBees CI controllers. It essentially allows a Pipeline to publish a notification event which will be trigger other Pipelines (across controllers) that are listening for that event. It consists of a Publishing Event and a Trigger Condition.
The Cross Team Collaboration feature has a configurable router for routing events and it needs to be configured on your managed controllers before you will be able to receive the event published by another Managed Controller. CloudBees CI CasC was used to pre-configure this for everyone.
Jenkinsfile
in the /templates/container-build
folder in your copy of the pipeline-template-catalog
repository, to listen for a notification event to be published by the upstream, or event publishing, job. We will do that by adding a trigger directive to then template Jenkinsfile Pipeline script.pipeline-template-catalog
repository in your workshop GitHub Organization, click on the Pull requests link and click on the Add Cross Team Collaboration Trigger pull request. triggers
block with an eventTrigger
and we have updated the when
condition to include triggeredBy 'EventTriggerCause'
: After first adding a new trigger
you must run the job at least once so that the trigger
is saved to the Jenkins job configuration on the controller (similar to setting the buildDiscarder
option
).
publishEvent event:jsonEvent("""
{
'image':{'name':'nginx','action':'update','tag':'1.22.0'}
}
"""), verbose: true
The entire Jenkins Pipeline containing the publishing event (also available in GitHub here):
pipeline {
agent none
stages {
stage('Update Docker Image') {
steps {
echo 'updated docker image nginx'
publishEvent event:jsonEvent("""
{
'image':{'name':'nginx','action':'update','tag':'1.22.0'}
}
"""), verbose: true
}
}
}
}
That event will be published across all Managed Controllers in the Workshop cluster via the CloudBees CI Cloud Operations Center event router, triggering everyone’s insurance-frontend-build Pipelines to run.
publishEvent
runs, everyone will see the open PR branch of their insurance-frontend-build job triggered by the JSON event and if you explore the Console Output of that build you will see that the BASE_IMAGE_TAG
value is coming from the published event payload instead of what is specified in the Dockerfile
of the insurance-frontend
repository.