title: How can I limit a Jenkins build step to ONLY given changeset?
body: <p>I'm using Jenkins declarative pipeline and I'm trying to execute a specific build stage only if changes were made ONLY in a specified directory.</p>
  
  <p>So my directory hierarchy looks something like this:</p>
  
  <pre><code>root
   ├─ some-directory
   |   ├─ sub-directory
   |   |   └─ file-1
   |   ├─ file-1
   |   └─ file-2
   ├─ another-directory
   |   ├─ file-1
   |   └─ file-2
   ├─ file-x
   └─ file-y
  </code></pre>
  
  <p>This is the current code:</p>
  
  <pre><code>stage ("Deploy branches") {
      agent any
  
      when { 
          allOf {
              not { branch 'master' }
              changeset "some-directory/**"
          }
      }
  
      steps {
          // do stuff
      }
  }
  </code></pre>
  
  <p>This deploys whenever something was changed in "some-directory" but also when something outside of "some-directory" was changed. I would like this step to run if nothing else but the contents of "some-directory" were changed.</p>
  
  <p>This is what <a href="https://jenkins.io/doc/book/pipeline/syntax/" rel="noreferrer">the Jenkins docs</a> say about the "changeset" directive:</p>
  
  <blockquote>
    <p>changeset</p>
    
    <p>Execute the stage if the build’s SCM changeset contains one or more files matching the given string or glob. Example: when { changeset "**/*.js" }</p>
    
    <p>By default the path matching will be case insensitive, this can be turned off with the caseSensitive parameter, for example: when { changeset glob: "ReadMe.*", caseSensitive: true }</p>
  </blockquote>
  
  <p>"If the changeset <em>contains</em> one or more files matching the given string or glob." means the pipelines works as designed, but what I nwould eed is</p>
  
  <p>"If the files in the changeset match <em>only</em> the given string or glob."</p>
  
  <p>Unfortunately I couldn't find anything about that in the docs or somewhere else on the internet.</p>
  
  <p>Do you have any suggestions how I could make this possible?</p>