Perry Hoekstra
Perry Hoekstra

Reputation: 2763

Jenkins Job Builder - Automatic Pipeline Job

Currently, in Jenkins Job Builder, I can specify downstream jobs through the publishers option like this:

- job-template:
    name: foo-one
    project-type: freestyle
    disabled: false
    ...
    publishers:
      - pipeline:
          project: foo-two

When the foo-one job is created, the downstream connection exists within Jenkins but the Build other projects entry is 'Build other projects (Manual Step)'. How do I indicate through Jenkins Job Builder that the downstream connection to job foo-two needs to be automated?

Upvotes: 1

Views: 929

Answers (2)

askb
askb

Reputation: 6768

Try using trigger-parameterized-builds for triggering downstream jobs.

- job-template:
    name: foo-one
    project-type: freestyle
    disabled: false
    ...

    publishers:
      - trigger-parameterized-builds:
          - project: 'foo-two'
            condition: UNSTABLE_OR_BETTER
            fail-on-missing: true

Upvotes: 0

Perry Hoekstra
Perry Hoekstra

Reputation: 2763

Could not figure out how to resolve the issue using Jenkins Job Builder publisher/pipeline tag. So, ended up:

  1. Configuring the foo-one job within Jenkins to kick off foo-two when foo-one completed successfully
  2. Retrieve the foo-one job's config.xml file through: curl -O http://localhost:8080/job/foo-one/config.xml
  3. Extracted the relevant XML from the config.xml file that controlled the downstream kickoff logic.
  4. Using the Jenkins Job Builder xml and publisher tags:

    - job-template:
        name: foo-one
        project-type: freestyle
        disabled: false
        ...
        publishers:
          - raw:
              xml: |
                <hudson.tasks.BuildTrigger>
                  <childProjects>foo-two</childProjects>
                  <threshold>
                    <name>SUCCESS</name>
                    <ordinal>0</ordinal>
                    <completeBuild>true</completeBuild>
                  </threshold>
                </hudson.tasks.BuildTrigger>
    

Upvotes: 1

Related Questions