feishuNotify.groovy 768 B

12345678910111213141516171819202122
  1. #!/usr/bin/env groovy
  2. import com.example.FeishuNotifier
  3. def call(String webhookUrl, String status) {
  4. def duration = currentBuild.durationString.replace(' and counting', '')
  5. def commitMsg = sh(returnStdout: true, script: "git log -1 --pretty=%B").trim()
  6. def author = sh(returnStdout: true, script: "git log -1 --pretty=%an").trim()
  7. def commitTime = sh(returnStdout: true, script: "git log -1 --pretty=%ci").trim() // 新增
  8. def branch = env.brach ?: env.GIT_BRANCH ?: env.BRANCH_NAME ?: 'unknown'
  9. new FeishuNotifier(this, webhookUrl).send(
  10. status,
  11. env.JOB_NAME,
  12. env.BUILD_NUMBER,
  13. env.BUILD_URL,
  14. duration,
  15. branch,
  16. commitMsg,
  17. author,
  18. commitTime
  19. )
  20. }