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 65aca1c commit 605e149
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions .jenkins/sign-macos-installer.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,24 @@ 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"
curl -H "Authorization: Bearer \$GITHUB_TOKEN" -s \
"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 \
curl -H "Authorization: Bearer \$GITHUB_TOKEN" -L \
"${artifact.archive_download_url}" --output ${ARTIFACT_NAME}.zip
"""

Expand Down

0 comments on commit 605e149

Please sign in to comment.