gatherInfo.groovy 959 B

1234567891011121314151617181920212223
  1. // vars/gatherInfo.groovy
  2. def call(String branchOverride = null) {
  3. def duration = currentBuild.durationString.replace(' and counting', '')
  4. def commitMsg = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
  5. def author = sh(returnStdout: true, script: 'git log -1 --pretty=%an').trim()
  6. def commitTime = sh(returnStdout: true, script: 'git log -1 --pretty=%ci').trim()
  7. def causes = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
  8. def builder = causes.isEmpty() ? 'auto' : causes[0].userId
  9. def branch = branchOverride ?: env.GIT_BRANCH ?: env.BRANCH_NAME ?: 'unknown'
  10. def buildUrl = env.BUILD_URL.replace('http://68.79.46.88:8080', 'https://jenkins.adwebcloud.com')
  11. return [
  12. duration : duration,
  13. commitMsg: commitMsg,
  14. author : author,
  15. commitTime: commitTime,
  16. branch : branch,
  17. buildUrl : buildUrl,
  18. builder : builder
  19. ]
  20. }