feat: add jenkins support
All checks were successful
jenkins-ci Build successful

This commit is contained in:
2026-01-26 10:49:38 +00:00
parent 73a935e393
commit 5003be30e1
2 changed files with 52 additions and 1 deletions

51
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,51 @@
pipeline {
agent any
environment {
GITEA_REPO_PATH = "lucas/n8n"
GITEA_API_URL = "https://gitea.lucasroyer.fr/api/v1"
}
stages {
stage('Check git...') {
steps {
checkout scm
}
}
stage('Deploy') {
steps {
echo "Deploy new n8n..."
sh "docker compose up -d --remove-orphans"
}
}
}
post {
always {
script {
echo "Send Gitea check..."
// Get and store SHA
def commitSha = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
// Convert from Jenkins to Gitea API
def buildState = (currentBuild.currentResult == 'SUCCESS') ? 'success' : 'failure'
def buildDesc = (currentBuild.currentResult == 'SUCCESS') ? 'Build successful' : 'Build failed'
// Send it to Gitea API with secret 'gitea-token'
withCredentials([string(credentialsId: 'gitea-token', variable: 'GITEA_TOKEN')]) {
// Use \$TOKEN to avoid jenkins to print token in logs
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"
}
success { echo "Success !" }
failure { echo "Failed." }
}
}

View File

@@ -5,7 +5,7 @@ services:
restart: always restart: always
volumes: volumes:
- n8n_data:/home/node/.n8n - n8n_data:/home/node/.n8n
- ./local-files:/files - /home/lucas/services/n8n/local-files:/files
environment: environment:
- N8N_HOST=n8n.lucasroyer.fr - N8N_HOST=n8n.lucasroyer.fr
- N8N_PORT=5678 - N8N_PORT=5678