Pārlūkot izejas kodu

#2023-12-10_CICD
ki build

lith 1 gadu atpakaļ
vecāks
revīzija
a43d27dcfb

+ 41 - 0
Publish/DevOps2/build-bash/22.add-suffix-to-app-version.bash

@@ -0,0 +1,41 @@
+set -e
+
+# export versionSuffix='.1234.preview'
+# bash 22.add-suffix-to-app-version.bash
+
+
+#---------------------------------------------------------------------
+# args
+args_="
+
+export versionSuffix='  '
+
+# "
+
+# remove spaces
+versionSuffix=${versionSuffix// /}
+
+#----------------------------------------------
+# basePath
+if [ -z "$basePath" ]; then basePath=$PWD/../../..; fi
+
+
+
+#----------------------------------------------
+echo "#1 get appVersion"
+# get csproj file with appVersion tag, if not exist get file with pack or publish tag
+csprojPath=$(find ${basePath} -name *.csproj -exec grep '<appVersion>' -l {} \; | head -n 1);
+if [ ! -f "$csprojPath" ]; then csprojPath=$(find ${basePath} -name *.csproj -exec grep '<pack>\|<publish>' -l {} \; | head -n 1);  fi
+if [ -f "$csprojPath" ]; then export appVersion=`grep '<Version>' "$csprojPath" | grep -oE '\>(.*)\<' | tr -d '<>/'`;  fi
+echo "appVersion from csproj: $appVersion"
+
+
+
+export nextAppVersion="${appVersion}${versionSuffix}"
+echo "nextAppVersion: $nextAppVersion"
+
+
+#----------------------------------------------
+echo "#2 change app version from [$appVersion] to [$nextAppVersion]" 
+sed -i 's/'"$appVersion"'/'"$nextAppVersion"'/g'  `find ${basePath} -name *.csproj -exec grep '<pack>\|<publish>' -l {} \;`
+

+ 2 - 2
Publish/DevOps2/jenkins-bash/CICD.ki.git_Multibranch.deploy.jenkinsfile

@@ -11,7 +11,7 @@ pipeline {
 
     environment {
         //APPNAME = "Sers"
-        APPNAME = "${env.JOB_BASE_NAME}"
+        APPNAME = "${env.projectName}"
 
 
         stageName = "ki"
@@ -63,7 +63,7 @@ pipeline {
             steps {
                 script {
                     echo "#2.1 change-app-version"
-                    sshCommand remote: remote, command:  "sh -c 'set -e; export versionSuffix=$versionSuffix;    cd $codePath/Publish/DevOps2/build-bash; source 20.change-app-version.bash;    echo \$nextAppVersion > $codePath/Publish/appVersion.txt '"
+                    sshCommand remote: remote, command:  "sh -c 'set -e; export versionSuffix=$versionSuffix;    cd $codePath/Publish/DevOps2/build-bash; source 22.add-suffix-to-app-version.bash;    echo \$nextAppVersion > $codePath/Publish/appVersion.txt '"
 		    
                     echo "#2.2 get app version"
 		    def data = readFile("Publish/appVersion.txt")