Reputation: 45
I want to get list of commit Id's shown in Git Changelog Plugin output as post-build action and iterate through it using java. Which script/method should I use?
Upvotes: 0
Views: 452
Reputation: 3520
With a Pipeline you can have the plugin return its context. And then loop through it. This works with plugin version 2.0 and later. In this example I list all commit id:s between develop and master. But you can specify type: 'COMMIT'
and specific commit if that is what you want.
node {
sh """
git clone [email protected]:jenkinsci/git-changelog-plugin.git .
"""
def changelogContext = gitChangelog returnType: 'CONTEXT',
from: [type: 'REF', value: 'master'],
to: [type: 'REF', value: 'develop']
changelogContext.commits.each { commit ->
println "Commit id: ${commit.hashFull}"
}
}
If you want to do this in pure Java, not a Pipeline. You can just use the lib.
Upvotes: 1