Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass ${CHANGES} to downstream job?

I have upstream job that polls SVN for changes. If changes are detected, the build is started. After the build, the upstream project calls downstream project to run test. I'm using "Trigger Parameterized Build".

I want that downstream project will be able to send an email with test results and SVN changes that cause to the build/test. But the problem is that if I'm using ${CHANGES} variable in downstream it appear to be empty.

How can I pass ${CHANGES} from upstream project to downstream project?

like image 302
Pupsik Avatar asked Oct 02 '22 14:10

Pupsik


1 Answers

You can get the change set or the values you need with groovy script:

def jenkins = Jenkins.getInstance()
def job = jenkins.getItem(jobName)
def bld = job.getBuildByNumber(buildNumber)
def changeSet = bld.getChangeSet()

then it dependents on which scm plugin you use, for example with git-plugin you can:

get the revision of each change:

changeSet.each{
    println it.getRevision()
}

get message for each change:

changeSet.each{
    println it.getMsg()
}

get affected paths:

changeSet.each{
   println it.getAffectedPaths()
}

get author name:

changeSet.each{
    println it.getAuthorName()
}

and many more actions

like image 176
Tidhar Klein Orbach Avatar answered Oct 18 '22 09:10

Tidhar Klein Orbach