Skip to content

Commit aa16929

Browse files
committed
Merge pull request #668 from lsfreitas/trigger-next-machine-image-gating
Update github action using curl method (cherry picked from commit 3d80eb7)
1 parent ffe6320 commit aa16929

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

.github/workflows/trigger_jenkins.yaml

+22-18
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,26 @@ jobs:
2525
fi
2626
echo "JOB_NAME=${FOLDER_NAME}/job/next-machine-image" >> $GITHUB_ENV
2727
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 }}
35-
36-
- name: Notify Slack on Failure
37-
if: failure()
28+
- name: Trigger Jenkins Job
29+
env:
30+
JENKINS_USER: ${{ secrets.JENKINS_USERNAME }}
31+
JENKINS_API_TOKEN: ${{ secrets.JENKINS_TOKEN }}
32+
JENKINS_URL: "https://jenkins.scylladb.com"
33+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
3834
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
35+
echo "Triggering Jenkins Job: $JOB_NAME"
36+
if ! curl -X POST "$JENKINS_URL/job/$JOB_NAME/buildWithParameters" --fail --user "$JENKINS_USER:$JENKINS_API_TOKEN" -i -v; then
37+
echo "Error: Jenkins job trigger failed"
38+
39+
# Send Slack message
40+
curl -X POST -H 'Content-type: application/json' \
41+
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
42+
--data '{
43+
"channel": "#releng-team",
44+
"text": "🚨 @here '$JOB_NAME' failed to be triggered, please check https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} for more details",
45+
"icon_emoji": ":warning:"
46+
}' \
47+
https://slack.com/api/chat.postMessage
48+
49+
exit 1
50+
fi

0 commit comments

Comments
 (0)