8
Jenkinsfile
vendored
8
Jenkinsfile
vendored
@@ -42,15 +42,15 @@ pipeline {
|
|||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
// Fetch the current commit SHA
|
// 1. Get current commit SHA
|
||||||
def commitSha = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
def commitSha = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
||||||
|
|
||||||
// Define build status and description based on current result
|
// 2. Determine build status for Gitea
|
||||||
def buildState = currentBuild.currentResult == 'SUCCESS' ? 'success' : 'failure'
|
def buildState = currentBuild.currentResult == 'SUCCESS' ? 'success' : 'failure'
|
||||||
def buildDesc = currentBuild.currentResult == 'SUCCESS' ? 'Build successful' : 'Build failed'
|
def buildDesc = currentBuild.currentResult == 'SUCCESS' ? 'Build successful' : 'Build failed'
|
||||||
|
|
||||||
// Notify Gitea using the API (requires credential in Jenkins)
|
// 3. Send status to Gitea API using our new 'gitea-token'
|
||||||
withCredentials([[$class: 'StringBinding', credentialsId: 'jenkins', variable: 'GITEA_TOKEN']]) {
|
withCredentials([string(credentialsId: 'gitea-token', variable: 'GITEA_TOKEN')]) {
|
||||||
sh """
|
sh """
|
||||||
curl -f -X POST "${GITEA_API_URL}/repos/${GITEA_REPO_PATH}/statuses/${commitSha}" \
|
curl -f -X POST "${GITEA_API_URL}/repos/${GITEA_REPO_PATH}/statuses/${commitSha}" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user