3

Configure Jenkins: Where it should trigger only when a particular folder changes.

For example: In a file directory: Sample/Folder/ there are 3 sub folders: F1, F2, F3. The jenkins build should be triggered when F3 is changed and should not include F1, F2 in the build. These 3 folders should be independent in regards to the build but should be in the same file directory. Also is there a way we can monitor the changes in the folders?

StormeHawke
  • 5,987
  • 5
  • 45
  • 73

1 Answers1

2

WIth Jenkins pipelines, start your job by querying the build changeset, as in here.

See if an when { anyOf { changeset directive is enough to build if and only when the changeset includes a specific element.

See the pipeline syntax built-in condition

changeset

Execute the stage if the build’s SCM changeset contains one or more files matching the given string or glob. Example: when { changeset "**/*.js" }


As noted by PFudd in the comments:

WARNING: When you create a new branch, the changeset will be empty on the first build. It's also empty if you click "Rebuild". See "Jenkins Pipeline how to check for an empty changelog"

The Jenkins team is aware of this, and due to the complexity of Git, they don't intend to fix it, because there is no universally-correct way to determine the right parent to compare with: see issue JENKINS-26354.

Reference: stackoverflow.com/questions/70307972/…

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • *DANGER* When you create a new branch, the changeset will be empty on the first build. It's also empty if you click "Rebuild". Reference: https://stackoverflow.com/questions/70307972/jenkins-pipeline-how-to-check-for-an-empty-changelog – PFudd Mar 10 '23 at 18:54
  • The Jenkins team is aware of this, and due to the complexity of Git, they don't intend to fix it, because there is no universally-correct way to determine the right parent to compare with: https://issues.jenkins.io/browse/JENKINS-26354 – PFudd Mar 10 '23 at 19:29