Andreas Fahrecker be80db8560
Some checks reported errors
andreas-personal/AndysAdguardHomeBlocklist/pipeline/head Something is wrong with the build of this commit
Add test command to check if file exists
2024-08-07 15:31:08 +02:00

76 lines
2.4 KiB
Groovy

#!groovy
pipeline {
agent {
label 'linux'
}
triggers {
cron('H 12,0 * * *')
}
stages {
stage('Compile Adblock List') {
when {
beforeAgent true;
branch 'main'
}
steps {
withGradle {
sh './gradlew :compileAdblockList'
}
// Verify the file exists
sh 'test -f out/andysadguardhomeblocklist.txt'
}
}
stage('Build/Push Docker Image') {
when {
beforeAgent true;
branch 'main'
}
agent {
label 'linux'
}
environment {
def tag = sh(returnStdout: true, script: 'git rev-parse --short=10 HEAD').trim()
PACKAGE_REGISTRY_CREDENTIALS = credentials('gitea-package-registry-jenkins-user')
}
stages {
stage('Build') {
steps {
// Verify the file exists
sh 'test -f out/andysadguardhomeblocklist.txt'
sh 'docker build -t gitea.fahrecker.com/andreas-personal/andysadguardhomeblocklist:dev-latest -t gitea.fahrecker.com/andreas-personal/andysadguardhomeblocklist:${tag} .'
}
}
stage('Login') {
steps {
sh 'docker login -u ${PACKAGE_REGISTRY_CREDENTIALS_USR} -p ${PACKAGE_REGISTRY_CREDENTIALS_PSW} gitea.fahrecker.com'
}
}
stage('Push') {
steps {
sh 'docker push gitea.fahrecker.com/andreas-personal/andysadguardhomeblocklist:${tag}'
sh 'docker push gitea.fahrecker.com/andreas-personal/andysadguardhomeblocklist:dev-latest'
}
}
}
post {
always {
sh 'docker logout gitea.fahrecker.com'
}
}
}
stage('Deploy') {
when {
beforeAgent true;
branch 'main'
}
agent {
label 'linux'
}
steps {
sh 'curl -H "Authorization: Bearer 2ykoFnTr3FWcqMLvaEthR79ffNfbTgzo" 10.55.0.2:8181/v1/update'
}
}
}
}