From 475ef2b702ffa1bcd3ed57ceb5215264d70d90ad Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 8 Jan 2026 20:06:59 +0100 Subject: [PATCH] New try --- Jenkinsfile | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index aa0b07d..6569a16 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,11 @@ pipeline { agent any + environment { + GITEA_REPO_PATH = "server/reverse-proxy" + GITEA_API_URL = "https://gitea.lucasroyer.fr/api/v1" + } + stages { stage('Check git...') { steps { @@ -36,10 +41,24 @@ pipeline { post { always { - step([ - $class: 'GiteaStatusNotifier', - context: 'Jenkins CI' - ]) + script { + // Fetch the current commit SHA + def commitSha = sh(script: 'git rev-parse HEAD', returnStdout: true).trim() + + // Define build status and description based on current result + def buildState = currentBuild.currentResult == 'SUCCESS' ? 'success' : 'failure' + def buildDesc = currentBuild.currentResult == 'SUCCESS' ? 'Build successful' : 'Build failed' + + // Notify Gitea using the API (requires 'gitea-token' credential in Jenkins) + withCredentials([string(credentialsId: 'gitea-token', variable: 'GITEA_TOKEN')]) { + sh """ + curl -f -X POST "${GITEA_API_URL}/repos/${GITEA_REPO_PATH}/statuses/${commitSha}" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d '{"state": "${buildState}", "target_url": "${env.BUILD_URL}", "description": "${buildDesc}", "context": "jenkins-ci"}' + """ + } + } echo "Clean unused image..." sh "docker image prune -f" }