Jenkins workflow (pipeline) - build job only when there are SCM changes
<p>I'm creating quite complicated workflow using the workflow-plugin (Renamed to Pipeline Plugin). For simplicity let's assume I need to build a job, but this job is quite expensive and it doesn't need to be build every time. Only when there are some SCM changes. </p>

<p>So let's call this job <strong><em>expensiveJob</em></strong> and it's Source Code Management there is <strong><em>SCMRepositoryA</em></strong>.</p>

<p>So I basically want to say </p>

<pre><code>build job: 'expensiveJob'
</code></pre>

<p>And I want to poll for SCM changes and build the job based on that information.</p>

<p>Is there a way how to do this?</p>

<p>My current solution is that I have to checkout in pipeline script the <strong><em>SCMRepositoryA</em></strong> and then check the <em>currentBuild.rawBuild.changeSets</em> seems to me like quite a lot of unnecessary work and possibly have to align with whatever Source Code Management changes in my jobs..</p>