From 165796aa5480121716f54bcd0363ae308f34bd70 Mon Sep 17 00:00:00 2001 From: yuobrezkov Date: Thu, 10 Apr 2025 11:57:48 +0300 Subject: [PATCH] added fn notify --- Jenkinsfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 47c15d6..f332293 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 {