Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if there are changes in git from pipeline

I'm working on a multibranch (A) job that is being triggered from another one (B). I want to do the deploy of my project only if there are changes in this project (A). By changes I mean from the last build of this job (I've seen the jenkins pannel gives you this info when you build, so I thought it would be possible to read it somewhere).

enter image description here)

So, is there any way of checking it in a pipeline?

like image 257
Jaime Alcántara Arnela Avatar asked Jun 28 '18 08:06

Jaime Alcántara Arnela


1 Answers

Finally I found the answer. If you just want to know if there are changes in that build you can do:

if(currentBuild.changeSets.size() > 0) {
    //There are changes
}
else {
    //No changes
}
like image 122
Jaime Alcántara Arnela Avatar answered Sep 28 '22 16:09

Jaime Alcántara Arnela