_gatherInfo.groovy 810 B

1234567891011121314151617
  1. // 注意:文件必须以下划线开头,表示「内部辅助」,不会被当成 DSL 步骤
  2. def call() {
  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 branch = env.BRANCH_NAME ?: env.GIT_BRANCH ?: 'unknown'
  8. def buildUrl = env.BUILD_URL.replace('http://68.79.46.88:8080', 'https://jenkins.adwebcloud.com')
  9. return [
  10. duration : duration,
  11. commitMsg: commitMsg,
  12. author : author,
  13. commitTime: commitTime,
  14. branch : branch,
  15. buildUrl : buildUrl
  16. ]
  17. }