Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getLastCommitHash() {
- return sh(script: 'git log --no-merges -n1 --pretty=format:"%H" HEAD', returnStdout: true).trim()
- }
- def isReleaseTag(string) {
- return string ==~ /^v\d+.\d+.\d+(-\S+)?$/
- }
- def getLatestTag() {
- return sh(script: 'git describe --abbrev=0 --tags', returnStdout: true).trim()
- }
- def isCommitTaggedWithVersion() {
- def latestTag = getLatestTag()
- def isVersionTag = isReleaseTag(latestTag)
- if (!isVersionTag) {
- return false
- }
- def commitForLatestTag = sh(script: "git rev-list -n 1 ${latestTag}", returnStdout: true).trim()
- def lastCommit = getLastCommitHash()
- return commitForLatestTag == lastCommit
- }
- def isPublishable() {
- return (isMaster() || isPR()) && isCommitTaggedWithVersion()
- }
Add Comment
Please, Sign In to add comment