Skip to content
Success

Changes

Summary

  1. refactor: encapsulate cloudevents sending into shared function (#4134) (commit: 2be41a5) (details)
Commit 2be41a54202fca6327f594c58220d11ef7834378 by noreply
refactor: encapsulate cloudevents sending into shared function (#4134)

## Summary

- Add `sendTestCaseRunReport()` function to `prow.groovy` shared library
- Replace inline curl commands with function call in all pipeline files
- CloudEvents URL centralized:
`https://internal2-do.pingcap.net/cloudevents-server/events`

## Changes

### Benefits
- **Reduced code duplication**: ~85% reduction (from 12 lines to 2 lines
per file)
- **Single source of truth**: CloudEvents URL configuration in one place
- **Easier maintenance**: Future URL changes only need one update
- **Cleaner code**: Declarative pipelines remain readable and concise

### Modified Files
- `libraries/tipipeline/vars/prow.groovy` - Added shared function
- 23 pipeline files - Replaced inline curl with function call

## Example

**Before:**
```groovy
sh label: 'Send event to cloudevents server', script: """timeout 10 \\
    curl --verbose --request POST --url https://internal2-do.pingcap.net/cloudevents-server/events \\
    --header "ce-id: \\\$(uuidgen)" \\
    --header "ce-source: \\\${JENKINS_URL}" \\
    --header 'ce-type: test-case-run-report' \\
    --header 'ce-repo: \\\${REFS.org}/\\${REFS.repo}' \\
    --header 'ce-branch: \\\${REFS.base_ref}' \\
    --header "ce-buildurl: \\\${BUILD_URL}" \\
    --header 'ce-specversion: 1.0' \\
    --header 'content-type: application/json; charset=UTF-8' \\
    --data @bazel-go-test-problem-cases.json || true
"""
```

**After:**
```groovy
script {
    prow.sendTestCaseRunReport("${REFS.org}/${REFS.repo}", "${REFS.base_ref}")
}
```
(commit: 2be41a5)
The file was modifiedpipelines/pingcap/tidb/release-7.6/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/latest/pull_integration_realcluster_test_next_gen/pipeline.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/latest/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-8.1/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-8.3/pull_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-8.2/pull_unit_test.groovy (diff)
The file was modifiedpipelines/tidbcloud/cloud-storage-engine/dedicated/pull_integration_realcluster_test_next_gen/pipeline.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-6.5/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-7.4/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/tikv/pd/latest/pull_integration_realcluster_test_next_gen/pipeline.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-6.5-20241101-v6.5.7/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-6.5-fips/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-7.5/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/latest/merged_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-8.5/pull_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-6.5-with-kv-timeout-feature/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-7.3/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-8.0/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-7.2/ghpr_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/latest/pull_unit_test_next_gen/pipeline.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-9.0-beta/pull_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-7.0/ghpr_unit_test.groovy (diff)
The file was modifiedlibraries/tipipeline/vars/prow.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-8.4/pull_unit_test.groovy (diff)
The file was modifiedpipelines/pingcap/tidb/release-7.1/ghpr_unit_test.groovy (diff)