Guest User

Untitled

a guest
Feb 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def getLastCommitHash() {
  2. return sh(script: 'git log --no-merges -n1 --pretty=format:"%H" HEAD', returnStdout: true).trim()
  3. }
  4.  
  5. def isReleaseTag(string) {
  6. return string ==~ /^v\d+.\d+.\d+(-\S+)?$/
  7. }
  8.  
  9. def getLatestTag() {
  10. return sh(script: 'git describe --abbrev=0 --tags', returnStdout: true).trim()
  11. }
  12.  
  13. def isCommitTaggedWithVersion() {
  14. def latestTag = getLatestTag()
  15. def isVersionTag = isReleaseTag(latestTag)
  16.  
  17. if (!isVersionTag) {
  18. return false
  19. }
  20.  
  21. def commitForLatestTag = sh(script: "git rev-list -n 1 ${latestTag}", returnStdout: true).trim()
  22. def lastCommit = getLastCommitHash()
  23.  
  24. return commitForLatestTag == lastCommit
  25. }
  26.  
  27. def isPublishable() {
  28. return (isMaster() || isPR()) && isCommitTaggedWithVersion()
  29. }
Add Comment
Please, Sign In to add comment