From 906fc5aae2f6d88218676f1dcd97e7bf8874aba2 Mon Sep 17 00:00:00 2001 From: yuobrezkov Date: Mon, 10 Mar 2025 16:58:38 +0300 Subject: [PATCH] getenv --- Jenkinsfile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ea5c429..a3877c8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,21 @@ -def notify(String giteaUser, String giteaPass, String repositoryUrl, String repositoryName, String prId, String buildStatus) { +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 '{"state": "${status}", "description": "${description}", "context": "ci/jenkins"}' \ - ${repositoryUrl}/api/v1/repos/${repositoryName}/statuses/${prId} + -d '{"context":"${context}","state": "${status}", "description": "${description}"}' \ + ${repositoryUrl}${repositoryName}/statuses/${commitHash} """ } @@ -22,6 +30,7 @@ pipeline { stage ('Initialize variables') { steps { script { + echo sh(script: 'env|sort', returnStdout: true) env.IMAGE_TAG = sh(script: "git describe --tags --abbrev=0", returnStdout: true).trim() } }