Skip to content

Commit

Permalink
fix: issue with jenkinsfile not aborting if gha is aborted
Browse files Browse the repository at this point in the history
  • Loading branch information
tlebon committed Dec 19, 2024
1 parent 8f75a49 commit 1ff7b42
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,32 @@ pipeline {
}
}
}

stage('Check GitHub Action Status') {
when { expression { BRANCH_NAME ==~ /PR-[0-9]+/ } }
steps {
stage('Check GitHub Action Status') {
when { expression { BRANCH_NAME ==~ /PR-[0-9]+/ } }
steps {
timeout(time: 15, unit: 'MINUTES') {
script {
def commit_hash = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
final String apiUrl = 'https://api.github.com/repos/wireapp/wire-webapp/actions/workflows/128602012/runs'
final String curlCmd = "curl -u \${CREDENTIALS} ${apiUrl}"
waitUntil {
final String output = sh(label: 'Check workflow', returnStdout: true, script: curlCmd)
final Object jsonData = readJSON(text: output)
final List workflowRuns = jsonData['workflow_runs']
echo("Looking for hash ${commit_hash}")
script {
def commit_hash = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
final String apiUrl = 'https://api.github.com/repos/wireapp/wire-webapp/actions/workflows/128602012/runs'
final String curlCmd = "curl -u \${CREDENTIALS} ${apiUrl}"
waitUntil {
final String output = sh(label: 'Check workflow', returnStdout: true, script: curlCmd)
final Object jsonData = readJSON(text: output)
final List workflowRuns = jsonData['workflow_runs']
echo("Looking for hash ${commit_hash}")

return workflowRuns.any { run -> checkWorkflowRun(run, commit_hash) }
return workflowRuns.any { run ->
def result = checkWorkflowRun(run, commit_hash)
if (run['conclusion'] == 'cancelled') {
error("GitHub Action was cancelled. Aborting Jenkins pipeline.")
}
return result
}
}
}
}
}
}
}
}

stage('Check deployment') {
steps {
Expand Down

0 comments on commit 1ff7b42

Please sign in to comment.