diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..288911a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,93 @@ +// Don't forget to add http://192.168.1.37:8080/gitea-webhook/post as a gitea webhook + +pipeline { + agent { label 'latex_no_docker' } + /* =============== + BEGIN USER CONFIG + ================== */ + + environment { + ORIGIN_FOLDER = "Ravenous_build.pdf" + MDBOOK_BUILD_DIR = "book" // Don't change, it allows the build script & mdBook to know where the book is + DEPLOY_DIR = "/mnt/books/Ravenous" // Important, all books are in /mnt/book + } + + stages { + stage('Checkout') { + steps { + checkout scm // Checkout intead of full clone + } + } + + stage('Install ravenous-tools') { + steps { + sh 'cargo install --git https://proxy.dandaedre.com/gitea/Ravenous/ravenous-tools.git || echo "mdBook already installed"' // Install the latest mdBooks + } + } + + // stage('Install plugins'){ + // steps { + // sh 'cargo install mdbook-admonish' // Change with desired plugins + // } + // } + + /* =============== + END USER CONFIG + ================== */ + + stage('Build Book') { + steps { + script { + if (env.BRANCH_NAME == 'origin/review' || env.BRANCH_NAME == 'review' || env.BRANCH_NAME == 'origin/dev-ci' || env.BRANCH_NAME == 'dev-ci') { + sh 'echo "Deploying to ${DEPLOY_DIR}_review"' + sh 'ravenous-tools make -t glossaries Ravenous.tex' + sh 'ravenous-tools make Ravenous.tex' + } else if (env.BRANCH_NAME == 'origin/master' || env.BRANCH_NAME == 'master') { + sh 'echo "Deploying to ${DEPLOY_DIR}"' + sh 'ravenous-tools make -t glossaries Ravenous.tex' + sh 'ravenous-tools make Ravenous.tex' + sh 'ravenous-tools make Ravenous.tex' // Second annoying make for correct references + } else { + echo "Unknown branch: ${env.BRANCH_NAME} — skipping build." + } + } + } + } + + stage('Deploy to Books') { + steps { + script { + if (env.BRANCH_NAME == 'origin/review' || env.BRANCH_NAME == 'review') { + sh 'echo "Deploying to ${DEPLOY_DIR}_review"' + sh 'mkdir -p ${DEPLOY_DIR}_review' + sh 'rsync -a --delete "${ORIGIN_FOLDER}" "${DEPLOY_DIR}_review/"' + } else if (env.BRANCH_NAME == 'origin/dev-ci' || env.BRANCH_NAME == 'dev-ci') { + sh 'echo "Deploying to ${DEPLOY_DIR}_dev"' + sh 'mkdir -p ${DEPLOY_DIR}_dev' + sh 'rsync -a --delete "${ORIGIN_FOLDER}" "${DEPLOY_DIR}_dev/"' + } else if (env.BRANCH_NAME == 'origin/master' || env.BRANCH_NAME == 'master') { + sh 'echo "Deploying to ${DEPLOY_DIR}"' + sh 'mkdir -p ${DEPLOY_DIR}' + sh 'rsync -a --delete "${ORIGIN_FOLDER}" "${DEPLOY_DIR}/"' + } else { + echo "Unknown branch: ${env.BRANCH_NAME} — skipping deploy steps." + } + } + } + } + } + + post { + success { + publishChecks conclusion: 'SUCCESS', name: 'Build Successful', summary: 'The build was successful', text: 'The build was sucessful', title: 'Build Successful' + echo '✅Site Deployed!' + } + failure { + publishChecks conclusion: 'FAILURE', name: 'Build Failed', summary: 'The build failed', text: 'The build was a failure', title: 'Build failed' + echo '❌Site Failed to Deploy' + } + unstable{ + publishChecks conclusion: 'ACTION_REQUIRED', name: 'Build Unstable', summary: 'Unstable build', text: 'Unstable build', title: 'Build Unstable' + } + } +}