Skip to content

Instantly share code, notes, and snippets.

@st-cyrill
Created September 27, 2022 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st-cyrill/faeb222b7449cb407e4ed4f9e5b30831 to your computer and use it in GitHub Desktop.
Save st-cyrill/faeb222b7449cb407e4ed4f9e5b30831 to your computer and use it in GitHub Desktop.
Trigger another build (Jenkins Project) by groovy example; Groovy Postbuild
import jenkins.*
import jenkins.model.*
import hudson.model.*
// pipeline job (org.jenkinsci.plugins.workflow.job.WorkflowJob)
def job = "foo"
// Trigger another build (Jenkins Project) Example
// NOTE: build is defined by Jenkins groovy plugin https://stackoverflow.com/a/36583480
// https://github.com/jenkinsci/workflow-job-plugin/blob/master/src/test/java/org/jenkinsci/plugins/workflow/job/console/DefaultLogStorageTest.java
Jenkins.instance.getItemByFullName(job).scheduleBuild2(0, new CauseAction(new Cause.UpstreamCause(manager.build)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment