CloudBees CI CasC was used to enable and configure Notifications for Cross Team Collaboration.
With CloudBees CI Notifications configured for our managed controllers, we can add an event trigger to a Pipeline template.
eventTrigger
using jmespathQuery
and adding a new stage
that will on run when the Pipeline is triggered by an EventTriggerCause
, and in that stage
we are using the getImageBuildEventPayload
Pipeline Shared Library step to extract the event payload. triggers {
eventTrigger jmespathQuery("event=='imagePush' && name=='maven'")
}
Because the pipeline-catalog-ops project is a Multibranch pipeline it will be triggered via a GitHub webhook on all code commits resulting in a re-import of the Pipeline Template Catalog.
Now that you have an eventTrigger
added to your Maven Pipeline Template, we need to create a job that will publish an event that will trigger it. Each of you will create a simple Pipeline job that will publish an event to imitate the real world scenario where a new maven
build image would be built and pushed - typically by another team on a different Managed Controller (Jenkins instance).
pipeline {
agent none
options {
timeout(time: 30, unit: 'MINUTES')
}
stages {
stage('Publish Event') {
steps {
publishEvent event: jsonEvent('{"event":"imagePush","name":"maven","tag":"3.6.3-openjdk-15"}'), verbose: true
}
}
}
}
4. Click the Build Now link in the left menu and then view the logs to see the Publishing event notification
Event JSON
. The verbose
option on the publishEvent
steps prints out the JSON being sent by the event in the logs.
5. Once the publish-event Pipeline job completes successfully you will see the main branch job of the simple-maven-app Mutlibranch project triggered.
6. Once the main branch job completes successfully you can see in the logs: new build image: maven:3.6.3-openjdk-15
, as specified by the event you published above and see that the build was triggered by an event.
For instructor led workshops please return to the workshop slides