From 0ababdce92f29217a752829785b2249fad8377f2 Mon Sep 17 00:00:00 2001 From: RebeccaNod1 Date: Sun, 10 Aug 2025 09:21:30 -0500 Subject: [PATCH] Add Jenkins CI/CD pipeline for LSL automation - Automatic LSL syntax validation on commits - Release package generation for main branch - Documentation updates - Discord/Slack notifications (optional) - Secure builds using dedicated agent --- Jenkinsfile | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f4ed146 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,176 @@ +pipeline { + agent any + + environment { + LSL_TOOLS_PATH = '/opt/lsl-tools' + PROJECT_NAME = 'peril' + NOTIFICATION_WEBHOOK = credentials('discord-webhook') // Optional + } + + triggers { + githubPush() // Trigger on GitHub push + pollSCM('H/5 * * * *') // Poll every 5 minutes as fallback + } + + stages { + stage('Checkout') { + steps { + echo "๐Ÿ” Checking out LSL project: ${PROJECT_NAME}" + checkout scm + } + } + + stage('LSL Validation') { + steps { + echo "๐Ÿ”ง Validating LSL syntax..." + sh ''' + python3 ${LSL_TOOLS_PATH}/lsl_validator.py /workspace/${PROJECT_NAME}/ + ''' + } + post { + failure { + echo "โŒ LSL validation failed!" + } + success { + echo "โœ… LSL validation passed!" + } + } + } + + stage('Preprocess Scripts') { + when { + anyOf { + branch 'main' + branch 'develop' + } + } + steps { + echo "๐Ÿ”„ Preprocessing LSL files..." + sh ''' + cd /workspace/${PROJECT_NAME} + for file in *.lsl; do + if [[ -f "$file" ]]; then + echo "Processing $file..." + python3 ${LSL_TOOLS_PATH}/lsl_preprocessor.py "$file" "processed_$file" + fi + done + ''' + } + } + + stage('Generate Release Package') { + when { + branch 'main' + } + steps { + echo "๐Ÿ“ฆ Creating release package..." + sh ''' + cd /workspace/${PROJECT_NAME} + + # Get version from git tag or use build number + VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v2.6.${BUILD_NUMBER}") + echo "Creating release ${VERSION}" + + # Create release directory + mkdir -p releases/${VERSION} + + # Copy LSL files + cp *.lsl releases/${VERSION}/ + + # Copy documentation + cp README.md CHANGELOG.md releases/${VERSION}/ 2>/dev/null || true + + # Create deployment notes + echo "Peril Game ${VERSION}" > releases/${VERSION}/DEPLOYMENT_NOTES.txt + echo "Build: ${BUILD_NUMBER}" >> releases/${VERSION}/DEPLOYMENT_NOTES.txt + echo "Date: $(date)" >> releases/${VERSION}/DEPLOYMENT_NOTES.txt + echo "Commit: ${GIT_COMMIT}" >> releases/${VERSION}/DEPLOYMENT_NOTES.txt + + # Create zip for easy download + cd releases + zip -r "${VERSION}.zip" ${VERSION}/ + ''' + + // Archive the release + archiveArtifacts artifacts: 'releases/**/*', followSymlinks: false + + // Create GitHub release (if using GitHub plugin) + script { + def version = sh(script: "cd /workspace/${PROJECT_NAME} && git describe --tags --abbrev=0 2>/dev/null || echo 'v2.6.${BUILD_NUMBER}'", returnStdout: true).trim() + echo "Release ${version} created successfully!" + } + } + } + + stage('Update Documentation') { + when { + branch 'main' + } + steps { + echo "๐Ÿ“š Updating project documentation..." + sh ''' + cd /workspace/${PROJECT_NAME} + + # Generate function list from LSL files + echo "# Project Functions" > FUNCTIONS.md + echo "" >> FUNCTIONS.md + echo "Auto-generated list of functions in this project:" >> FUNCTIONS.md + echo "" >> FUNCTIONS.md + + for file in *.lsl; do + if [[ -f "$file" ]]; then + echo "## $file" >> FUNCTIONS.md + echo "" >> FUNCTIONS.md + grep -n "^[a-zA-Z_][a-zA-Z0-9_]*(" "$file" | head -20 >> FUNCTIONS.md || true + echo "" >> FUNCTIONS.md + fi + done + ''' + } + } + + stage('Notify Success') { + when { + branch 'main' + } + steps { + echo "๐ŸŽ‰ Build completed successfully!" + script { + // Optional: Send Discord/Slack notification + // Only if webhook is configured + if (env.NOTIFICATION_WEBHOOK) { + sh ''' + curl -X POST ${NOTIFICATION_WEBHOOK} \ + -H "Content-Type: application/json" \ + -d "{\\"content\\": \\"โœ… Peril LSL project build #${BUILD_NUMBER} completed successfully! New release ready for deployment.\\"}" + ''' + } + } + } + } + } + + post { + always { + echo "๐Ÿงน Cleaning up workspace..." + cleanWs(cleanWhenAborted: false, cleanWhenFailure: false, cleanWhenNotBuilt: false, cleanWhenSuccess: true, cleanWhenUnstable: false) + } + + failure { + echo "๐Ÿ’ฅ Build failed! Check the logs above." + script { + if (env.NOTIFICATION_WEBHOOK) { + sh ''' + curl -X POST ${NOTIFICATION_WEBHOOK} \ + -H "Content-Type: application/json" \ + -d "{\\"content\\": \\"โŒ Peril LSL project build #${BUILD_NUMBER} failed! Check Jenkins for details.\\"}" + ''' + } + } + } + + success { + echo "๐ŸŽฏ Build completed successfully!" + } + } +}