diff --git a/README.md b/README.md index 66e2cf3..72c0921 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,6 @@ This repository contains the Jenkins Pipelines used for the EDC CI: https://ci.eclipse.org/edc/ -## [github-action](./github-action.groovy) -Starts a GitHub action workflow and waits for its completion. - -Variables: -- `OWNER`: the organization name -- `REPO`: the repository name -- `WORKFLOW`: the workflow to be launched - ## [nightly.groovy](./nightly.groovy) Builds and publish all the components every night. diff --git a/github-action.groovy b/github-action.groovy deleted file mode 100644 index 8b890f0..0000000 --- a/github-action.groovy +++ /dev/null @@ -1,35 +0,0 @@ -pipeline { - agent any - stages { - stage("start-github-workflow") { - steps { - withCredentials([usernamePassword(credentialsId: 'github-bot', passwordVariable: 'BOTTOKEN', usernameVariable: 'BOT')]) { - sh './scripts/start_build.sh $OWNER $REPO $WORKFLOW $BOT $BOTTOKEN' - } - } - } - stage("wait-until-job-created") { - steps { - timeout(30) { - withCredentials([usernamePassword(credentialsId: 'github-bot', passwordVariable: 'BOTTOKEN', usernameVariable: 'BOT')]) { - // this will create a file "run.id" that contains the run-id - sh './scripts/wait_job_created.sh $OWNER $REPO $WORKFLOW $BOT $BOTTOKEN' - } - } - } - } - stage("wait-until-job-completed") { - steps { - script { - run_id = readFile('run.id') - currentBuild.displayName = "$OWNER/$REPO/$WORKFLOW/$run_id" - } - timeout(60) { - withCredentials([usernamePassword(credentialsId: 'github-bot', passwordVariable: 'BOTTOKEN', usernameVariable: 'BOT')]) { - sh './scripts/wait_job_completed.sh $OWNER $REPO $BOT $BOTTOKEN' - } - } - } - } - } -} diff --git a/scripts/github_action.sh b/scripts/github_action.sh index 7f863ad..8a98f3c 100755 --- a/scripts/github_action.sh +++ b/scripts/github_action.sh @@ -17,7 +17,7 @@ elif [ "$#" -eq 5 ]; then PARAMS=(-u "$USER":"$PWD" -H "Accept: application/vnd.github.v3+json") else - echo "Usage: start_build.sh OWNER REPO WORKFLOW USER [PWD]" + echo "Usage: github_action.sh OWNER REPO WORKFLOW USER [PWD]" echo "OWNER = the owner/org of the github repo" echo "REPO = the name of the github repo" echo "WORKFLOW = the name of the workflow file to run, or its ID" diff --git a/scripts/start_build.sh b/scripts/start_build.sh deleted file mode 100755 index d0ed4fa..0000000 --- a/scripts/start_build.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -OWNER="$1" -REPO="$2" -WORKFLOW="$3" -USER="$4" -PWD="$5" - -if [ "$#" -eq 4 ]; then - # use cURL with a Personal Access Token - echo "Using USER as personal access token for the GitHub API" - PARAMS=(-H "Authorization: Bearer $USER" -H "Accept: application/vnd.github.v3+json") - -elif [ "$#" -eq 5 ]; then - # use basic auth with cUrl - echo "Using USER/PWD authentication for the GitHub API" - PARAMS=(-u "$USER":"$PWD" -H "Accept: application/vnd.github.v3+json") - -else - echo "Usage: start_build.sh OWNER REPO WORKFLOW USER [PWD]" - echo "OWNER = the owner/org of the github repo" - echo "REPO = the name of the github repo" - echo "WORKFLOW = the name of the workflow file to run, or its ID" - echo "USER = the username to use for authentication against the GitHub API, or an API token" - echo "PWD = the password of USER. if not specified, USER will be interpreted as token" - exit 1 -fi - -curl --location --request POST "https://api.github.com/repos/$OWNER/$REPO/actions/workflows/$WORKFLOW/dispatches" \ - "${PARAMS[@]}" \ - --data-raw '{ - "ref": "main" - }' diff --git a/scripts/wait_job_completed.sh b/scripts/wait_job_completed.sh deleted file mode 100755 index bfebf7a..0000000 --- a/scripts/wait_job_completed.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -OWNER="$1" -REPO="$2" -USER="$3" -PWD="$4" - -if [ "$#" -eq 3 ]; then - # use cURL with a Personal Access Token - echo "Using USER as personal access token for the GitHub API" - PARAMS=(-H "Authorization: Bearer $USER" -H "Accept: application/vnd.github.v3+json") -elif [ "$#" -eq 4 ]; then - # use basic auth with cUrl - echo "Using USER/PWD authentication for the GitHub API" - PARAMS=(-u "$USER":"$PWD" -H "Accept: application/vnd.github.v3+json") -else - echo "Usage: wait_job_completion.sh OWNER REPO USER [PWD]" - echo "OWNER = the owner/org of the github repo" - echo "REPO = the name of the github repo" - echo "USER = the username to use for authentication against the GitHub API, or an API token" - echo "PWD = the password of USER. if not specified, USER will be interpreted as token" - exit 1 -fi - -RUN_ID=$(cat ./run.id) - -while [ "$status" != "completed" ]; do - json=$(curl --fail -sSl "${PARAMS[@]}" -X GET "https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${RUN_ID}") - status=$(echo "$json" | jq -r '.status') - conclusion=$(echo "$json" | jq -r '.conclusion') - echo "$(date) :: Run $RUN_ID is $status" - sleep 30 # sleep for 30 seconds before we check again, lets keep API requests low -done - -echo "Run completed, conclusion: $conclusion" diff --git a/scripts/wait_job_created.sh b/scripts/wait_job_created.sh deleted file mode 100755 index 8fbad72..0000000 --- a/scripts/wait_job_created.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -OWNER="$1" -REPO="$2" -WORKFLOW="$3" -USER="$4" -PWD="$5" - -if [ "$#" -eq 4 ]; then - # use cURL with a Personal Access Token - echo "Using USER as personal access token for the GitHub API" - PARAMS=(-H "Authorization: Bearer $USER" -H "Accept: application/vnd.github.v3+json") - -elif - [ "$#" -eq 5 ] -then - # use basic auth with cUrl - echo "Using USER/PWD authentication for the GitHub API" - PARAMS=(-u "$USER":"$PWD" -H "Accept: application/vnd.github.v3+json") - -else - echo "Usage: start_build.sh OWNER REPO WORKFLOW USER [PWD]" - echo "OWNER = the owner/org of the github repo" - echo "REPO = the name of the github repo" - echo "WORKFLOW = the name of the workflow file to run, or its ID" - echo "USER = the username to use for authentication against the GitHub API, or an API token" - echo "PWD = the password of USER. if not specified, USER will be interpreted as token" - exit 1 -fi - -numRuns=0 -echo "Waiting for run to start" -while [ "$numRuns" -le "0" ]; do - sleep 3 - # fetch the latest run triggered by a workflow_dispatch event - runs=$(curl --fail -sSl "${PARAMS[@]}" -X GET "https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW}/runs?event=workflow_dispatch&status=in_progress") - numRuns=$(echo "$runs" | jq -r '.total_count') - echo " - found $numRuns" -done - -# contains the ID of the latest/most recent run -RUN_ID=$(echo "$runs" | jq -r '.workflow_runs[0].id') - -echo "$RUN_ID" > ./run.id