Changed Jenkinsfile for notify

pull/17/head v1.0.3
yuobrezkov 2025-03-11 12:58:31 +03:00
parent 588f278621
commit 888cc70187
1 changed files with 25 additions and 0 deletions

25
Jenkinsfile vendored
View File

@ -1,3 +1,24 @@
def notify(
String context,
String giteaUser,
String giteaPass,
String repositoryUrl,
String repositoryName,
String commitHash,
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 '{"context":"${context}","state": "${status}", "description": "${description}"}' \
${repositoryUrl}deployer3000/${repositoryName}/statuses/${commitHash}
"""
}
pipeline { pipeline {
agent any agent any
environment { environment {
@ -66,6 +87,10 @@ pipeline {
http://git.entcor/api/v1/repos/deployer3000/integration-module/pulls/${prId}/merge http://git.entcor/api/v1/repos/deployer3000/integration-module/pulls/${prId}/merge
""" """
echo "PR ${prId} merged successfully into master!" echo "PR ${prId} merged successfully into master!"
def context = "test-org/integration-module/pipeline/pr-${env.CHANGE_TARGET}"
def commitHash = sh(script: "git rev-parse HEAD~1", returnStdout: true).trim()
notify(context, GITEA_USER, GITEA_PASS, env.GITEA_REPOSITORY_URL, "integration-module", commitHash, "success")
} }
} }
} }