<p>I see your using a <code>freestyle</code> job, but this is where Jenkins <code>pipelines</code> shine.</p>
<pre><code>node() {
    
    try {
        // do your testing
    } catch (Exception e) {
        build(job: 'detailed_logging')
    }
}
</code></pre>
<p>You can find more detail in the <a href="https://www.jenkins.io/doc/pipeline/steps/pipeline-build-step/" rel="nofollow noreferrer">build</a> step documentation.</p>

CC BY-SA 4.0
2022-08-11T22:44:52.933Z
2022-08-11T22:44:52.933Z
Levi
<p>Use the Parameterized Trigger (<a href="https://plugins.jenkins.io/parameterized-trigger/" rel="nofollow noreferrer">https://plugins.jenkins.io/parameterized-trigger/</a>) in your Post Build Actions.  In my example I did not pass any parameters to the new job.</p>
<p><a href="https://i.sstatic.net/d2srV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/d2srV.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-07-06T14:03:24.647Z
2022-07-06T14:03:24.647Z
John
<p>There is a system that periodically runs on Jenkins and that I follow with selenium. (I'm checking its performance on &quot;manager/status&quot; page in Tomcat). I want it to trigger the second job, which will make detailed logging (*1) only when there is an error in the job. How can I do it?</p>
<p>When the first job is successful I can trigger the 2nd job but <strong>what I need is to trigger the 2nd job when the first job fails</strong><a href="https://i.sstatic.net/QtCZr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QtCZr.png" alt="enter image description here" /></a></p>
<p>(*1)
I'm checking the geoserver performance. &quot;http://serverip:port/geoserver/rest/monitor/requests.csv?order=totalTime;ASC&quot; will download the performance values on geoserver server in &quot;xls&quot; format on jenkins server.</p>

<jenkins>
Jenkins trigger the 2nd job when the first job fails
mahmudao2325
# Jenkins trigger the 2nd job when the first job fails

(Asked by: username_0 on 2022-06-23)

There is a system that periodically runs on Jenkins and that I follow with selenium. (I'm checking its performance on "manager/status" page in Tomcat). I want it to trigger the second job, which will make detailed logging (\*1) only when there is an error in the job. How can I do it?

When the first job is successful I can trigger the 2nd job but **what I need is to trigger the 2nd job when the first job fails**[![enter image description here](https://i.sstatic.net/QtCZr.png)](https://i.sstatic.net/QtCZr.png)

(\*1)
I'm checking the geoserver performance. "http://serverip:port/geoserver/rest/monitor/requests.csv?order=totalTime;ASC" will download the performance values on geoserver server in "xls" format on jenkins server.

**Tags:** jenkins


---

## 2 answers

### Answer by username_1 on 2022-08-11. Score: 0 | Accepted answer

I see your using a freestyle job, but this is where Jenkins pipelines shine.
node() {
    
    try {
        // do your testing
    } catch (Exception e) {
        build(job: 'detailed_logging')
    }
}

You can find more detail in the build step documentation.


---

### Answer by username_2 on 2022-07-06. Score: 0

Use the Parameterized Trigger (<https://plugins.jenkins.io/parameterized-trigger/>) in your Post Build Actions. In my example I did not pass any parameters to the new job.

[![enter image description here](https://i.sstatic.net/d2srV.png)](https://i.sstatic.net/d2srV.png)


---

