Update pipeline_lib.groovy

This commit is contained in:
surtexx 2023-11-13 17:21:58 +02:00 committed by GitHub
parent 5daa969744
commit 68fc95af0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,51 +1,53 @@
if(env.CHANGE_ID != null){ def run(){
pipeline{ if(env.CHANGE_ID != null){
agent any pipeline{
stages { agent any
stage ("build") { stages {
steps { stage ("build") {
echo "Running build automation..." steps {
sh './mvnw checkstyle:checkstyle' echo "Running build automation..."
sh './mvnw verify' sh './mvnw checkstyle:checkstyle'
sh './mvnw clean package -DskipTests=true' sh './mvnw verify'
sh './mvnw clean package -DskipTests=true'
}
} }
} stage ("Build Docker Image") {
stage ("Build Docker Image") { steps {
steps { script{
script{ app = docker.build("surtexx/mr:${GIT_COMMIT[0..7]}", "-f Dockerfile1 .")
app = docker.build("surtexx/mr:${GIT_COMMIT[0..7]}", "-f Dockerfile1 .") }
}
}
stage ("Push Docker Image") {
steps {
script{
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') {
app.push("${GIT_COMMIT[0..7]}")
app.push("latest")
}
}
} }
} }
} }
stage ("Push Docker Image") { }
steps { }
script{ else if(env.BRANCH_NAME == "main"){
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') { pipeline{
app.push("${GIT_COMMIT[0..7]}") agent any
app.push("latest") stages{
} stage ("Build Docker Image") {
} steps {
} script{
} app = docker.build("surtexx/main", "-f Dockerfile1 .")
} }
} }
} }
else if(env.BRANCH_NAME == "main"){ stage ("Push Docker Image") {
pipeline{ steps {
agent any script{
stages{ docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') {
stage ("Build Docker Image") { app.push("latest")
steps { }
script{
app = docker.build("surtexx/main", "-f Dockerfile1 .")
}
}
}
stage ("Push Docker Image") {
steps {
script{
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') {
app.push("latest")
} }
} }
} }