Test for notifying
parent
481676f8a4
commit
231bc84ccc
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue