Jenkins Pipeline: Get build output from slave agent
<h1>Background</h1>

<p>Let's say I have two jobs, one 'Pipeline Job' and one 'Build Job'. The 'Pipeline Job' runs on master and is of course a pipeline (using groovy). Then for a build part in the pipeline I use a slave running on Windows, the 'Build Job', which is responsible for building something I can't do on the master. The master is also running on Windows but lack some software needed for the specific build.</p>

<h1>The Question</h1>

<p>I have a groovy script that looks something like this:</p>

<pre><code>#!groovy
node {
    stage('Environment Preparation') {
        // fetches stuff and sets up the environment on master
    }
    stage('Unit Testing') {
        // some testing
    }
    stage('Build on Slave') {
        def slaveJob = build job: 'BuildJob'
    }
}
</code></pre>

<p>It works fine, where 'BuildJob' is "Restrict where this project can be run", i.e., on the slave. </p>

<p>My issue is that I want the output from 'BuildJob' to print in the pipeline logs. Do you have some clever ways of how this could be done? I'm open for everything, so if you know of more clever ways to start the 'BuildJob' etc. I'm eager to here it.</p>

<p>Thanks!</p>