jenkinsjenkins-job-builder

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?


Solution

  • 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>