Copilot commented on code in PR #443:
URL: https://github.com/apache/trafficserver-ci/pull/443#discussion_r3414439591


##########
jenkins/github/toplevel.pipeline:
##########
@@ -1,13 +1,52 @@
 TOP_JOB_DESC = "Builds:\\n"
 
+String githubUrl() {
+       return env.GITHUB_URL ?: GITHUB_REPO_GIT_URL.replace("git://", 
"https://";)
+}
+
+void waitForMirrorRefs() {
+       def mirrorUrl = githubUrl()
+
+       echo "Waiting for ${mirrorUrl} to mirror PR #${GITHUB_PR_NUMBER}"
+       withEnv(["MIRROR_URL=${mirrorUrl}"]) {
+               timeout(time: 2, unit: 'MINUTES') {

Review Comment:
   Avoid logging the full mirror URL here: if `GITHUB_URL` is ever configured 
with embedded credentials (e.g. https://token@host/repo.git), this `echo` will 
leak them into the Jenkins build log. Consider sanitizing the URL for logging 
(or omit it) while still using the full value for `git ls-remote`.



##########
jenkins/github/toplevel.pipeline:
##########
@@ -1,13 +1,52 @@
 TOP_JOB_DESC = "Builds:\\n"
 
+String githubUrl() {
+       return env.GITHUB_URL ?: GITHUB_REPO_GIT_URL.replace("git://", 
"https://";)
+}
+
+void waitForMirrorRefs() {
+       def mirrorUrl = githubUrl()
+
+       echo "Waiting for ${mirrorUrl} to mirror PR #${GITHUB_PR_NUMBER}"
+       withEnv(["MIRROR_URL=${mirrorUrl}"]) {
+               timeout(time: 2, unit: 'MINUTES') {
+                       waitUntil {
+                               def status = sh(
+                                       label: 'Check mirrored PR refs',
+                                       returnStatus: true,
+                                       script: '''#!/bin/bash
+set +x

Review Comment:
   `git ls-remote` may block on credential prompts or hide upstream failures in 
pipelines. Setting `GIT_TERMINAL_PROMPT=0` avoids hangs, and `set -o pipefail` 
ensures the pipeline fails if `git ls-remote` fails (instead of the exit status 
being masked by `awk`).



##########
jenkins/github/github_polling.pipeline:
##########
@@ -1,13 +1,52 @@
 TOP_JOB_DESC = "Builds:\\n"
 
+String githubUrl() {
+       return env.GITHUB_URL ?: GITHUB_REPO_GIT_URL.replace("git://", 
"https://";)
+}
+
+void waitForMirrorRefs() {
+       def mirrorUrl = githubUrl()
+
+       echo "Waiting for ${mirrorUrl} to mirror PR #${GITHUB_PR_NUMBER}"
+       withEnv(["MIRROR_URL=${mirrorUrl}"]) {
+               timeout(time: 2, unit: 'MINUTES') {

Review Comment:
   Avoid logging the full mirror URL here: if `GITHUB_URL` is ever configured 
with embedded credentials (e.g. https://token@host/repo.git), this `echo` will 
leak them into the Jenkins build log. Consider sanitizing the URL for logging 
(or omit it) while still using the full value for `git ls-remote`.



##########
jenkins/github/toplevel.pipeline:
##########
@@ -1,13 +1,52 @@
 TOP_JOB_DESC = "Builds:\\n"
 
+String githubUrl() {
+       return env.GITHUB_URL ?: GITHUB_REPO_GIT_URL.replace("git://", 
"https://";)
+}
+
+void waitForMirrorRefs() {
+       def mirrorUrl = githubUrl()
+
+       echo "Waiting for ${mirrorUrl} to mirror PR #${GITHUB_PR_NUMBER}"

Review Comment:
   This helper logic (`githubUrl()` / `waitForMirrorRefs()`) is duplicated 
verbatim in both `toplevel.pipeline` and `github_polling.pipeline`. Duplicated 
pipeline logic tends to drift over time; consider extracting it into a shared 
Groovy file / Jenkins shared library var so the readiness gate behavior stays 
consistent.



##########
jenkins/github/github_polling.pipeline:
##########
@@ -1,13 +1,52 @@
 TOP_JOB_DESC = "Builds:\\n"
 
+String githubUrl() {
+       return env.GITHUB_URL ?: GITHUB_REPO_GIT_URL.replace("git://", 
"https://";)
+}
+
+void waitForMirrorRefs() {
+       def mirrorUrl = githubUrl()
+
+       echo "Waiting for ${mirrorUrl} to mirror PR #${GITHUB_PR_NUMBER}"
+       withEnv(["MIRROR_URL=${mirrorUrl}"]) {
+               timeout(time: 2, unit: 'MINUTES') {
+                       waitUntil {
+                               def status = sh(
+                                       label: 'Check mirrored PR refs',
+                                       returnStatus: true,
+                                       script: '''#!/bin/bash
+set +x

Review Comment:
   `git ls-remote` may block on credential prompts or hide upstream failures in 
pipelines. Setting `GIT_TERMINAL_PROMPT=0` avoids hangs, and `set -o pipefail` 
ensures the pipeline fails if `git ls-remote` fails (instead of the exit status 
being masked by `awk`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to