This repository has been archived on 2024-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
Andreas Fahrecker ee3d446ba2
Some checks failed
andreas-personal/AndysAdguardHomeBlocklist/pipeline/head There was a failure building this commit
Remove npm install step outside gradle
2024-04-16 05:49:19 +02:00

83 lines
2.4 KiB
Groovy

#!groovy
pipeline {
agent {
label 'linux'
}
triggers {
cron('H 12,0 * * *')
}
stages {
stage('Checkout') {
when {
beforeAgent true;
branch 'main'
}
steps {
sh 'git checkout main'
}
}
stage('Check last Commit') {
when {
beforeAgent true;
branch 'main'
}
steps {
script {
def causes = currentBuild.getBuildCauses()
echo "Build causes: ${causes}"
def causedByScmEvent = causes.any {
it._class == 'hudson.triggers.SCMTrigger$SCMTriggerCause' ||
it._class == 'jenkins.branch.BranchEventCause'
}
echo "Caused by SCM event: ${causedByScmEvent}"
if (!causedByScmEvent) {
echo 'Not triggered by SCM, continuing build'
} else if (sh(script: 'git log -1 --pretty=format:"%an"', returnStdout: true).trim() == 'Jenkins') {
currentBuild.result = 'ABORTED'
error('Last commit was by Jenkins, skipping build')
} else {
echo 'Last commit was not by Jenkins, continuing build'
}
}
}
}
stage('Compile Adblock List') {
when {
beforeAgent true;
branch 'main'
}
steps {
withGradle {
sh './gradlew :compileAdblockList'
}
sh '''
git add out/andysadguardhomeblocklist.txt
git commit -m "Update Compiled Adblock List"
'''
}
}
stage('git push') {
when {
beforeAgent true;
branch 'main'
}
steps {
withCredentials([
gitUsernamePassword(credentialsId: 'gitea-jenkins-user-token')
]) {
sh '''
git pull origin main
git push
'''
}
}
}
}
post {
always {
deleteDir()
}
}
}