<p>Make B as a Pipeline job and give it some <a href="https://www.jenkins.io/doc/book/pipeline/syntax/#parameters" rel="nofollow noreferrer">build parameters</a>.  Humans will be able to trigger this build with whatever parameters they want using the &quot;Build With Parameters&quot; button in the web UI.</p>
<p>Then, in your Pipeline script for A, trigger the build using <a href="https://www.jenkins.io/doc/pipeline/steps/pipeline-build-step/" rel="nofollow noreferrer">the built-in build step</a>.  This will allow job A to trigger B with whatever parameters are necessary:</p>
<pre><code>build(
  job: 'Job B',
  parameters: [
    string(name: 'parameterName1', value: &quot;some parameter value&quot;),
    string(name: 'parameterName2', value: &quot;some parameter value&quot;),
    // etc.
  ],
)
</code></pre>

CC BY-SA 4.0
2021-06-03T16:00:47.293Z
2021-06-03T16:00:47.293Z
jayhendren
<p>I hope it's okay to ask for recommendations here. I'm very new to devops, and am trying to get into the headspace of involved technologies and workflows.</p>
<p>I've created a webhook in my Bitbucket project that posts to <code>http://JENKINS_URL/generic-webhook-trigger/invoke</code>. Using techniques described <a href="https://www.youtube.com/watch?v=8mrJNkofxq4" rel="nofollow noreferrer">here</a>, the corresponding Pipeline build in Jenkins only acts if the event was the pushing of a git tag.</p>
<p><strong>I would like this Jenkins Pipeline build to trigger <em>another</em> Jenkins build that is triggerable by a human -- what are (good/proper) ways to organize this?</strong> In other words: if <code>A</code> is a Pipeline build triggered by a generic webhook, I would like <code>A</code> to figure out some variable values and trigger <code>B</code>, passing it those variables, and I would like for a human to be able to manually trigger <code>B</code> using human-supplied variables.</p>
<p>In my naivete, I imagined <code>A</code> being a Pipeline build because they offer the option to use a Pipeline script, which is the only way I'm currently aware of that offers a way to access the Post content parameters. I.e. if <code>A</code> was a freestyle build with a shell script, I don't know how I'd access the Post content.</p>
<p>However, when <code>A</code> is a Pipeline build there is no <code>Post-build Actions</code> section in the Jenkins UI -- i.e. I don't see how a Pipeline build can trigger a subsequent build.</p>
<p>From naivete, again, I envisioned a Pipeline build triggering a freestyle build because the Pipeline build allows accessing generic webhook post content, and the freestyle build is human-triggerable, and can be parameterized so that either the human or the calling Pipeline build can supply those parameters.</p>
<p>(I hope I might also direct some eyeballs to a separate, but related, question about passing parameters to parameterized builds: <a href="https://devops.stackexchange.com/questions/13915/why-is-parameter-not-propagated-to-post-build-parameterized-build">Why is parameter not propagated to post-build parameterized build?</a>)</p>

<jenkins><jenkins-pipeline><pipeline>
What are ways to structure a webhook-triggered job that triggers a human-triggerable job?
StoneThrow
# What are ways to structure a webhook-triggered job that triggers a human-triggerable job?

(Asked by: username_0 on 2021-05-14)

I hope it's okay to ask for recommendations here. I'm very new to devops, and am trying to get into the headspace of involved technologies and workflows.

I've created a webhook in my Bitbucket project that posts to `http://JENKINS_URL/generic-webhook-trigger/invoke`. Using techniques described [here](https://www.youtube.com/watch?v=8mrJNkofxq4), the corresponding Pipeline build in Jenkins only acts if the event was the pushing of a git tag.

**I would like this Jenkins Pipeline build to trigger *another* Jenkins build that is triggerable by a human -- what are (good/proper) ways to organize this?** In other words: if `A` is a Pipeline build triggered by a generic webhook, I would like `A` to figure out some variable values and trigger `B`, passing it those variables, and I would like for a human to be able to manually trigger `B` using human-supplied variables.

In my naivete, I imagined `A` being a Pipeline build because they offer the option to use a Pipeline script, which is the only way I'm currently aware of that offers a way to access the Post content parameters. I.e. if `A` was a freestyle build with a shell script, I don't know how I'd access the Post content.

However, when `A` is a Pipeline build there is no `Post-build Actions` section in the Jenkins UI -- i.e. I don't see how a Pipeline build can trigger a subsequent build.

From naivete, again, I envisioned a Pipeline build triggering a freestyle build because the Pipeline build allows accessing generic webhook post content, and the freestyle build is human-triggerable, and can be parameterized so that either the human or the calling Pipeline build can supply those parameters.

(I hope I might also direct some eyeballs to a separate, but related, question about passing parameters to parameterized builds: [Why is parameter not propagated to post-build parameterized build?](https://devops.stackexchange.com/questions/13915/why-is-parameter-not-propagated-to-post-build-parameterized-build))

**Tags:** jenkins, jenkins-pipeline, pipeline


---

## 1 answers

### Answer by username_1 on 2021-06-03. Score: 1

Make B as a Pipeline job and give it some build parameters.  Humans will be able to trigger this build with whatever parameters they want using the "Build With Parameters" button in the web UI.
Then, in your Pipeline script for A, trigger the build using the built-in build step.  This will allow job A to trigger B with whatever parameters are necessary:
build(
  job: 'Job B',
  parameters: [
    string(name: 'parameterName1', value: "some parameter value"),
    string(name: 'parameterName2', value: "some parameter value"),
    // etc.
  ],
)


---

