From 308c745f0963e4a2573f32af11e083057966f2ff Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 26 Jan 2026 10:56:27 +0000 Subject: [PATCH] chore: add jenkins support --- Jenkinsfile | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e7fcef9 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,59 @@ +pipeline { + agent any + + environment { + GITEA_REPO_PATH = "lucas/onlyoffice" + GITEA_API_URL = "https://gitea.lucasroyer.fr/api/v1" + } + + stages { + stage('Check git...') { + steps { + checkout scm + } + } + stage('Deploy') { + steps { + withCredentials([ + file(credentialsId: 'onlyoffice-app-env', variable: 'APP_ENV_PATH'), + ]) { + echo "Deploy new onlyoffice server..." + sh """ + cp "\$APP_ENV_PATH" app.env + docker compose up -d --remove-orphans + rm -f app.env + """ + } + } + } + } + + 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." } + } +} \ No newline at end of file