Test for notifying
Build succeeded Details
test-org/trust-module-frontend/pipeline/pr-main Build succeeded Details

pull/10/head 1.0.3
yuobrezkov 2025-03-10 15:29:13 +03:00
parent 481676f8a4
commit 231bc84ccc
1 changed files with 16 additions and 0 deletions

16
Jenkinsfile vendored
View File

@ -1,3 +1,16 @@
def notify(String giteaUser, String giteaPass, String repositoryUrl, String repositoryName, String prId, String buildStatus) {
def status = buildStatus == 'success' ? 'success' : 'failure'
def description = buildStatus == 'success' ? 'Build succeeded' : 'Build failed'
sh """
curl -X POST \
-u "${giteaUser}:${giteaPass}" \
-H "Content-Type: application/json" \
-d '{"state": "${status}", "description": "${description}", "context": "ci/jenkins"}' \
${repositoryUrl}/api/v1/repos/${repositoryName}/statuses/${prId}
"""
}
pipeline {
agent any
environment {
@ -50,6 +63,7 @@ pipeline {
echo "Attempting to merge PR ${env.CHANGE_ID} into master..."
withCredentials([usernamePassword(credentialsId: 'gitea_creds', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_PASS')]) {
def prId = env.CHANGE_ID
// Merge the PR
sh """
curl -X POST \
-u "${GITEA_USER}:${GITEA_PASS}" \
@ -58,6 +72,8 @@ pipeline {
http://git.entcor/api/v1/repos/deployer3000/trust-module-frontend/pulls/${prId}/merge
"""
echo "PR ${prId} merged successfully into master!"
// Notify Gitea with the PR status
notify(GITEA_USER, GITEA_PASS, GITEA_REPOSITORY_URL, "trust-module-frontend", prId, "success")
}
}
}