feishuNotify.groovy 808 B

1234567891011121314151617181920
  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 branch = env.GIT_BRANCH ?: env.BRANCH_NAME ?: 'unknown'
  8. new FeishuNotifier(this, webhookUrl).send(
  9. status, // 1
  10. env.JOB_NAME, // 2
  11. env.BUILD_NUMBER, // 3
  12. env.BUILD_URL, // 4
  13. duration, // 5
  14. branch, // 6
  15. commitMsg, // 7
  16. author // 8
  17. )
  18. }