How to pass ${CHANGES} to downstream job?

后端 未结 2 1252
余生分开走
余生分开走 2021-01-13 01:15

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.

2条回答
  •  一向
    一向 (楼主)
    2021-01-13 01:54

    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

提交回复
热议问题