This commit is contained in:
61
Jenkinsfile
vendored
Executable file
61
Jenkinsfile
vendored
Executable file
@@ -0,0 +1,61 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
GITEA_REPO_PATH = "lucas/nextcloud"
|
||||
GITEA_API_URL = "https://gitea.lucasroyer.fr/api/v1"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Check git...') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
withCredentials([
|
||||
file(credentialsId: 'nextcloud-app-env', variable: 'APP_ENV_PATH'),
|
||||
file(credentialsId: 'nextcloud-db-env', variable: 'DB_ENV_PATH')
|
||||
]) {
|
||||
echo "Deploy new nextcloud..."
|
||||
sh """
|
||||
cp "\$APP_ENV_PATH" app.env
|
||||
cp "\$DB_ENV_PATH" db.env
|
||||
docker compose up -d --remove-orphans
|
||||
rm -f app.env db.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." }
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,12 @@ services:
|
||||
restart: always
|
||||
volumes:
|
||||
- app:/var/www/html
|
||||
- ./app/config:/var/www/html/config
|
||||
- ./app/custom_apps:/var/www/html/custom_apps
|
||||
- ./app/data:/var/www/html/data
|
||||
- ./app/themes:/var/www/html/themes
|
||||
- ./zz-php-fpm-custom.conf:/usr/local/etc/php-fpm.d/zz-php-custom.conf
|
||||
- ./opcache-recommended.ini:/usr/local/etc/php/conf.d/opcache-recommended.ini
|
||||
- /home/lucas/services/nextcloud/app/config:/var/www/html/config
|
||||
- /home/lucas/services/nextcloud/app/custom_apps:/var/www/html/custom_apps
|
||||
- /home/lucas/services/nextcloud/app/data:/var/www/html/data
|
||||
- /home/lucas/services/nextcloud/app/themes:/var/www/html/themes
|
||||
- /home/lucas/services/nextcloud/zz-php-fpm-custom.conf:/usr/local/etc/php-fpm.d/zz-php-custom.conf
|
||||
- /home/lucas/services/nextcloud/opcache-recommended.ini:/usr/local/etc/php/conf.d/opcache-recommended.ini
|
||||
env_file:
|
||||
- app.env
|
||||
networks:
|
||||
@@ -45,9 +45,9 @@ services:
|
||||
container_name: nextcloud-web
|
||||
restart: always
|
||||
volumes:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||
- /home/lucas/services/nextcloud/Caddyfile:/etc/caddy/Caddyfile:ro
|
||||
- app:/var/www/html:ro
|
||||
- ./app/custom_apps:/var/www/html/custom_apps:ro
|
||||
- /home/lucas/services/nextcloud/app/custom_apps:/var/www/html/custom_apps:ro
|
||||
depends_on:
|
||||
- nextcloud-app
|
||||
networks:
|
||||
|
||||
Reference in New Issue
Block a user