I tried to use changeset in a scripted pipeline like the following, but it does not work as expected. It would be great if there is a way to achieve it in a
scripted syntax, as I do not want to change our Jenkinsfile to a declarative one.
I’m not so sure it’s the best way to do it, but I think you could achieve the desired functionality by using the git command to check for changes in a specific file.
Here is an untested example of how you could maybe do this:
The checkout scm command fetches the repository.
The sh step runs a git diff command to get the list of changed files between the last two commits.
The script checks if file.json is in the list of changed files. If not, it marks the build as unstable.