Skip to content

Commit

Permalink
try to fix jenkins / groovy string interpolation warning, refs #15213
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertHilbrich committed Dec 13, 2024
1 parent 43f1901 commit e9d00c6
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .jenkins/sign-macos-installer.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,35 @@ spec:
// Step 1: Find the last successful workflow run
def workflowRunsResponse = sh(
script: """
curl -H "Authorization: Bearer \$GITHUB_TOKEN" -s \
"https://api.github.com/repos/\$REPO_OWNER/\$REPO_NAME/actions/workflows/\$WORKFLOW_ID/runs?status=success"
// curl -H "Authorization: Bearer \$GITHUB_TOKEN" -s \
"https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/workflows/${WORKFLOW_ID}/runs?status=success"
""",
returnStdout: true
).trim()

// Parse workflow runs JSON response using JsonSlurper
def workflowRuns = new JsonSlurper().parseText(workflowRunsResponse)
if (!workflowRuns.workflow_runs || workflowRuns.workflow_runs.size() == 0) {
error("No successful workflow runs found for workflow: ${WORKFLOW_ID}")
}
def lastRunId = workflowRuns.workflow_runs[0].id

// Step 2: Get the artifact list for the last successful run
def artifactsResponse = sh(
script: """
curl -H "Authorization: Bearer \$GITHUB_TOKEN" -s \
"https://api.github.com/repos/\$REPO_OWNER/\$REPO_NAME/actions/runs/${lastRunId}/artifacts"
"https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runs/${lastRunId}/artifacts"
""",
returnStdout: true
).trim()

// Parse artifacts JSON response using JsonSlurper
def artifacts = new JsonSlurper().parseText(artifactsResponse)
def artifact = artifacts.artifacts.find { it.name == ARTIFACT_NAME }
if (!artifact) {
error("Artifact '${ARTIFACT_NAME}' not found for run ID: ${lastRunId}")
}

// Step 3: Download the artifact
sh """
curl -H "Authorization: Bearer \$GITHUB_TOKEN" -L \
Expand Down

0 comments on commit e9d00c6

Please sign in to comment.