diff --git a/Jenkinsfile b/Jenkinsfile index 4746d4d307d..62abf64bf26 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 {