From 45b0b9d1aab7de45b314e2c98bb73bcab797da13 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Fri, 5 Jul 2024 21:55:05 +0200
Subject: [PATCH] OZG-5907 upload branch jars to nexus

---
 Jenkinsfile | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index ef44d538b0..8b0c808cab 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -44,6 +44,7 @@ pipeline {
                 }
             }
         }
+   
         stage('Client') {
             environment {
                 FORCE_COLOR = 'false'
@@ -83,6 +84,28 @@ pipeline {
 //                }
 //            }
         }
+
+        stage('Set Version') {
+          when {
+            not {
+                anyOf {
+                    branch 'master'
+                    branch 'release'
+                }
+            }
+          }
+          steps {
+                script {
+                    FAILED_STAGE=env.STAGE_NAME
+                    JAR_TAG = getPomVersion(pomFile).replace("SNAPSHOT", "${env.BRANCH_NAME}-SNAPSHOT")
+                }
+                configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
+                    sh "mvn -s $MAVEN_SETTINGS versions:set -DnewVersion=${JAR_TAG} -DprocessAllModules=true"
+                    
+                }
+          }
+        }
+
         stage('Server') {
             steps {
                 script {
@@ -120,12 +143,6 @@ pipeline {
             }
         }
         stage('Deploy Maven Artifacts to Nexus') {
-            when {
-                anyOf {
-                    branch 'master'
-                    branch 'release'
-                }
-            }
             steps {
                 script {
                     FAILED_STAGE = env.STAGE_NAME
@@ -133,6 +150,7 @@ pipeline {
 
                 configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
                     sh 'mvn --no-transfer-progress -s $MAVEN_SETTINGS -pl -alfa-client -DskipTests deploy'
+                    sh "mvn -s $MAVEN_SETTINGS versions:revert"
                 }
             }
         }
-- 
GitLab