Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions .github/workflows/jenkins_tests_execution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
#push:
# branches: [ main ]
pull_request:
branches: [ gha_jenkins_script ]
branches: [ main, gha_jenkins_script, execution_test_branch ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -18,7 +18,7 @@ jobs:

if: >-
github.event.pull_request.user.login == 'lukaszgda' ||
github.event.pull_request.user.login == 'user2'
github.event.pull_request.user.login == 'user1'

# The type of runner that the job will run on
runs-on: self-hosted
Expand All @@ -30,40 +30,43 @@ jobs:
- name: Clone the git repo
uses: actions/checkout@v2

# Executing jenkins job
- name: Executing jenkins job
# Github base ref
- name: Github base ref
run: |
echo ${{ github.event.pull_request.branch }}
echo ${{ github.base_ref }}

# Executing jenkins job
# - name: Executing jenkins job
# run: |
# curlOutput=`curl -XPOST --insecure --silent --show-error -u $jenkins_user:$jenkins_token $job_address/buildWithParameters?token=$job_token`
# if [[ "$curlOutput" == *"Error"* ]]; then
# echo $curlOutput
# exit 1
# fi
- name: Executing jenkins job
run: |
curlOutput=`curl -XPOST -i --insecure -u $jenkins_user:$jenkins_token ${job_address}/buildWithParameters?token=$job_token`
if [[ "$curlOutput" == *"Error"* ]]; then
echo $curlOutput
exit 1
fi

# sleep 10
queueLocation=`grep location <<< "$curlOutput" | grep -Eo '[0-9]{2,}'`

# curlJsonBuildOutput=`curl --insecure -u $jenkins_user:$jenkins_token $job_address/lastBuild/api/json | jq -r '.building'`
sleep 10

# while [[ "$curlJsonBuildOutput" == "true" ]]
# do
# sleep 10
# curlJsonBuildOutput=`curl --insecure -u $jenkins_user:$jenkins_token $job_address/lastBuild/api/json | jq -r '.building'`
# done
job=`curl -X GET --insecure -u $jenkins_user:$jenkins_token ${queueAddress}/$queueLocation/api/json | jq -r .executable.url`

# - name: Show Jenkins job log
# run: |
# curl --insecure -u $jenkins_user:$jenkins_token $job_address/lastBuild/consoleText
echo "job=$job" >> $GITHUB_ENV
curlJsonBuildOutput=`curl --insecure -u $jenkins_user:$jenkins_token ${job}api/json | jq -r '.building'`

# - name: Validating job's status
# run: |
# curlJsonResultOutput=`curl --insecure -u $jenkins_user:$jenkins_token $job_address/lastBuild/api/json | jq -r '.result'`
echo $curlJsonBuildOutput

while [[ "$curlJsonBuildOutput" == "true" ]]
do
sleep 10
curlJsonBuildOutput=`curl --insecure -u $jenkins_user:$jenkins_token ${job}api/json | jq -r '.building'`
done

- name: Validating job's status
run: |
curlJsonResultOutput=`curl --insecure -u $jenkins_user:$jenkins_token ${{ env.job }}api/json | jq -r '.result'`

# if [[ "$curlJsonResultOutput" == "FAILURE" ]]; then
# echo "Jenkins job failed!"
# exit 1
# fi
if [[ "$curlJsonResultOutput" -ne "SUCCESS" ]]; then
echo "Jenkins job failed!"
exit 1
fi