-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding first tests with jenkins downloads, refs #15213
- Loading branch information
1 parent
6489fa2
commit 2a3bc57
Showing
1 changed file
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
inheritFrom 'my-agent-pod' | ||
yaml """ | ||
apiVersion: v1 | ||
kind: Pod | ||
spec: | ||
containers: | ||
- name: jnlp | ||
resources: | ||
limits: | ||
memory: "1Gi" | ||
cpu: "500m" | ||
requests: | ||
memory: "1Gi" | ||
cpu: "500m" | ||
- name: ubuntu-sumo | ||
image: ghcr.io/eclipse/eclipse-sumo-build-ubuntu:latest | ||
tty: true | ||
resources: | ||
limits: | ||
memory: "2Gi" | ||
cpu: "1" | ||
requests: | ||
memory: "2Gi" | ||
cpu: "1" | ||
command: | ||
- cat | ||
env: | ||
- name: "MAVEN_OPTS" | ||
value: "-Duser.home=/home/jenkins" | ||
volumeMounts: | ||
- name: settings-xml | ||
mountPath: /home/jenkins/.m2/settings.xml | ||
subPath: settings.xml | ||
readOnly: true | ||
- name: settings-security-xml | ||
mountPath: /home/jenkins/.m2/settings-security.xml | ||
subPath: settings-security.xml | ||
readOnly: true | ||
- name: m2-repo | ||
mountPath: /home/jenkins/.m2/repository | ||
volumes: | ||
- name: settings-xml | ||
secret: | ||
secretName: m2-secret-dir | ||
items: | ||
- key: settings.xml | ||
path: settings.xml | ||
- name: settings-security-xml | ||
secret: | ||
secretName: m2-secret-dir | ||
items: | ||
- key: settings-security.xml | ||
path: settings-security.xml | ||
- name: m2-repo | ||
emptyDir: {} | ||
""" | ||
} | ||
} | ||
environment { | ||
GITHUB_TOKEN = env.GH_TOKEN | ||
REPO_OWNER = "eclipse-sumo" | ||
REPO_NAME = "sumo" | ||
WORKFLOW_ID = "build-macos.yml" | ||
ARTIFACT_NAME = "macos-14-installer-unsigned" | ||
} | ||
stages { | ||
stage('Download macOS Installer Artifact') { | ||
steps { | ||
container('ubuntu-sumo') { | ||
script { | ||
// 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" | ||
""", | ||
returnStdout: true | ||
).trim() | ||
def workflowRuns = readJSON text: 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" | ||
""", | ||
returnStdout: true | ||
).trim() | ||
def artifacts = readJSON text: 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 \ | ||
"${artifact.archive_download_url}" --output ${ARTIFACT_NAME}.zip | ||
""" | ||
|
||
// Step 4: Extract the artifact | ||
sh "unzip -o ${ARTIFACT_NAME}.zip -d artifact" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |