diff --git a/Jenkinsfile b/Jenkinsfile index dee8e77f0..575bc290c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,63 @@ pipeline { agent { label 'pipeline-agent' } stages { - stage ('Build') { + stage ('Checkstyle') { + when { + changeRequest() + } steps { - sh 'mvn checkstyle:check' + sh './mvnw checkstyle:checkstyle' + } + post { + always { + archiveArtifacts artifacts: 'target/checkstyle-result.xml', fingerprint: true + } + } + } + stage ('Test') { + when { + changeRequest() + } + steps { + sh './mvnw test -B' + } + } + stage ('Build') { + when { + changeRequest() + } + steps { + sh './mvnw clean package -DskipTests' + } + } + stage ('Docker Push to MR') { + when { + changeRequest() + } + environment { + IMAGE = credentials('docker_image_name') + REGISTRY = credentials('nexus_url_main') + } + steps { + script { + def GIT_COMMIT_SHORT = env.GIT_COMMIT.take(7) + echo "Git commit short is ${GIT_COMMIT_SHORT}" + } + } + } + stage ('Docker Push to Main') { + when { + branch 'main' + } + environment { + IMAGE = credentials('docker_image_name') + REGISTRY = credentials('nexus_url_main') + } + steps { + script { + def GIT_COMMIT_SHORT = env.GIT_COMMIT.take(7) + echo "Git commit short is ${GIT_COMMIT_SHORT}" + } } } }