Skip to content

Commit 9d9bd6c

Browse files
lsfreitasyaronkaikov
authored andcommitted
Use github action instead of curl method to trigger jenkins
Improves the way we trigger next-machine-image job using a dedicated github action instead of using curl. Fixes: #659 (cherry picked from commit aa2866a)
1 parent 00f9926 commit 9d9bd6c

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed
+21-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Trigger Jenkins Job
1+
name: Trigger next-machine-image gating
22

33
on:
44
push:
@@ -13,6 +13,8 @@ jobs:
1313
run: |
1414
if [[ "${{ github.ref_name }}" == "next" ]]; then
1515
FOLDER_NAME="scylla-master"
16+
elif [[ "${{ github.ref_name }}" == "next-enterprise" ]]; then
17+
FOLDER_NAME="scylla-enterprise"
1618
else
1719
VERSION=$(echo "${{ github.ref_name }}" | awk -F'-' '{print $2}')
1820
if [[ "$VERSION" =~ ^202[0-4]\.[0-9]+$ ]]; then
@@ -23,25 +25,22 @@ jobs:
2325
fi
2426
echo "JOB_NAME=${FOLDER_NAME}/job/next-machine-image" >> $GITHUB_ENV
2527
26-
- name: Trigger Jenkins Job
27-
env:
28-
JENKINS_USER: ${{ secrets.JENKINS_USERNAME }}
29-
JENKINS_API_TOKEN: ${{ secrets.JENKINS_TOKEN }}
30-
JENKINS_URL: "https://jenkins.scylladb.com"
31-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
32-
run: |
33-
echo "Triggering Jenkins Job: $JOB_NAME"
34-
if ! curl -X POST "$JENKINS_URL/job/$JOB_NAME/buildWithParameters" --fail --user "$JENKINS_USER:$JENKINS_API_TOKEN" -i -v; then
35-
echo "Error: Jenkins job trigger failed"
36-
37-
# Send Slack message
38-
curl -X POST -H 'Content-type: application/json' \
39-
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
40-
--data '{
41-
"channel": "#releng-team",
42-
"text": "🚨 @here '$JOB_NAME' failed to be triggered, please check https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} for more details"
43-
}' \
44-
https://slack.com/api/chat.postMessage
28+
- name: Start Jenkins Job
29+
uses: scylladb-actions/[email protected]
30+
with:
31+
job_name: ${{ env.JOB_NAME }}
32+
base_url: https://jenkins.scylladb.com
33+
user: ${{ secrets.JENKINS_USERNAME }}
34+
password: ${{ secrets.JENKINS_TOKEN }}
4535

46-
exit 1
47-
fi
36+
- name: Notify Slack on Failure
37+
if: failure()
38+
run: |
39+
echo "Action failed, sending Slack alert..."
40+
curl -X POST -H 'Content-type: application/json' \
41+
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
42+
--data '{
43+
"channel": "#releng-team",
44+
"text": "🚨 @here '${{ env.JOB_NAME }}' failed to be triggered, please check https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} for more details."
45+
}' \
46+
https://slack.com/api/chat.postMessage

0 commit comments

Comments
 (0)