New try
This commit is contained in:
27
Jenkinsfile
vendored
27
Jenkinsfile
vendored
@@ -1,6 +1,11 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
GITEA_REPO_PATH = "server/reverse-proxy"
|
||||||
|
GITEA_API_URL = "https://gitea.lucasroyer.fr/api/v1"
|
||||||
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Check git...') {
|
stage('Check git...') {
|
||||||
steps {
|
steps {
|
||||||
@@ -36,10 +41,24 @@ pipeline {
|
|||||||
|
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
step([
|
script {
|
||||||
$class: 'GiteaStatusNotifier',
|
// Fetch the current commit SHA
|
||||||
context: 'Jenkins CI'
|
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..."
|
echo "Clean unused image..."
|
||||||
sh "docker image prune -f"
|
sh "docker image prune -f"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user