HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

when does currentBuild.changeSets in Jenkins gets filled?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
jenkinsfilleddoeswhenchangesetscurrentbuildgets

Problem

Some background: The project I'm working on is in SVN. Very very large. A lot of tests are running on Jenkins. I want to implement a new tests which should be executed only if files in certain directory have been changed.

The idea that I had was:

  • to trigger the job using a pollSCM every ten minutes



  • check the files in currentBuild.changeSets. If a file contains the directory, continue.



  • Only then I do a full checkout of the repository, compile, and run the tests.



But before I write the code, I was wondering when does currentBuild.changeSets? Will it have the required information when triggered by a pollSCM? I could not find this in the documentation

Yes, this could be done in a better way using git and hooks and other tools but that's what I have right now.

Solution

It will be set after any checkout steps (or derivatives of checkout such as git or svn).

So for instance:

println(currentBuild.changeSets) // should print an empty set

checkout(scm)

println(currentBuild.changeSets) // should print out any changes in the current build

Code Snippets

println(currentBuild.changeSets) // should print an empty set

checkout(scm)

println(currentBuild.changeSets) // should print out any changes in the current build

Context

StackExchange DevOps Q#4773, answer score: 5

Revisions (0)

No revisions yet.