diff --git a/Jenkinsfile b/Jenkinsfile index 2e83346..5af466b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 { agent any environment { @@ -66,6 +87,10 @@ pipeline { http://git.entcor/api/v1/repos/deployer3000/integration-module/pulls/${prId}/merge """ 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") } } }