Modifica jenkinsfile x usare uno script "comune" (primo test...)

This commit is contained in:
Samuele E. Locatelli
2017-11-08 16:26:09 +01:00
parent 5c8d4d2288
commit d94845ba73
Vendored
+45 -36
View File
@@ -1,4 +1,5 @@
pipeline {
// Scripted Pipeline Syntax
agent none
environment {
EMAIL_RECIPIENTS = 'samuele@steamware.net'
@@ -28,23 +29,24 @@ pipeline {
else {
currentBuild.description = "BUILD ${env.versionNumber}"
}
}
/* CAMBIO numero versione in file sorgente!!! */
}
// CAMBIO numero versione + checkout NuGet in file sorgente!!!
bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
bat "e:\\nuget.exe restore ${WORKSPACE}\\MAPO.sln"
}
}
stage('Build') {
agent any
steps {
script {
// options { buildDiscarder(logRotator(numToKeepStr: '30')) }
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '30', daysToKeepStr: '30', numToKeepStr: '30')), pipelineTriggers([])])
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '180', artifactNumToKeepStr: '30', daysToKeepStr: '360', numToKeepStr: '30')), pipelineTriggers([])])
// CAMBIO numero versione + checkout NuGet in file sorgente!!!
bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
bat "e:\\nuget.exe restore ${WORKSPACE}\\MAPO.sln"
}
script {
/* compilo installers in base al BRANCH del cliente... */
if (env.BRANCH_NAME == "develop") {
/* CAMBIO numero versione in file sorgente!!! */
bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
parallel (
LANDING: {
sleep 5
@@ -73,24 +75,22 @@ pipeline {
failFast: false)
}
else {
echo 'Nothing to Build...'
echo 'Niente x Build (limitata a develop)...'
}
}
}
}
stage('Test') {
steps {
echo 'Testing.. 2 be done...'
}
}
stage('Deploy') {
agent any
steps {
script {
// CAMBIO numero versione + checkout NuGet in file sorgente!!!
bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
bat "e:\\nuget.exe restore ${WORKSPACE}\\MAPO.sln"
}
script {
/* DEPLOY condizionale: develop / master / demo_ovh */
if (env.BRANCH_NAME == "master") {
/* CAMBIO numero versione in file sorgente!!! */
bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
if (env.BRANCH_NAME == "master") {
parallel (
LANDING: {
sleep 0
@@ -132,8 +132,6 @@ pipeline {
failFast: false)
}
if (env.BRANCH_NAME == "OVH-DEMO") {
/* CAMBIO numero versione in file sorgente!!! */
bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
parallel (
// LANDING: {
// sleep 5
@@ -170,11 +168,10 @@ pipeline {
stage('Installers') {
agent any
steps {
// in primis compilo a seconda del branch... TUTTO tranne develop...
// in primis cambio versione e NuGet
script {
// CAMBIO numero versione in file sorgente!!!
// CAMBIO numero versione + checkout NuGet in file sorgente!!!
bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// restore nuget packages
bat "e:\\nuget.exe restore ${WORKSPACE}\\MAPO.sln"
}
// ora mi occupo delle operazioni di compressione e copia...
@@ -221,19 +218,18 @@ pipeline {
bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\MP-Tablet\\ReleaseClienti\\${env.BRANCH_NAME}\" \"E:\\Staging\\byProd\\MP\\${env.BRANCH_NAME}\\MP-TAB\" "
}
// manifest.xml: aggiorno versNumber ed URL del branch di update...
bat "fart.exe MP-Tablet\\Resources\\manifest.xml 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
bat "fart.exe MP-Tablet\\Resources\\manifest.xml {{BRANCHNAME}} ${env.BRANCH_NAME} || EXIT /B 0"
bat "fart.exe MP-Tablet\\Resources\\ChangeLog.html {{CURRENT-REL}} ${env.versionNumber} || EXIT /B 0"
writeFile file: 'MP-Tablet\\changeLog.log', text: "${getChangeString()}"
powershell '(Get-Content MP-Tablet\\Resources\\ChangeLog.html) | ForEach-Object { $_ -replace \"{{LAST-CHANGES}}\", \"${getChangeString()}\" } | Set-Content MP-Tablet\\Resources\\ChangeLog.html'
// copio ed esporto in IIS02 i vari files .xml, .html, .zip
bat "xcopy /y MP-Tablet\\Resources\\manifest.xml c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
bat "xcopy /y MP-Tablet\\Resources\\ChangeLog.html c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
bat "xcopy /y MP-Tablet\\Resources\\logoSteamware.png c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
// pubblico su server deploy!
publishToDeployServer("MP-Tablet\\Resources", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB")
// // manifest.xml: aggiorno versNumber ed URL del branch di update...
// bat "fart.exe MP-Tablet\\Resources\\manifest.xml 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// bat "fart.exe MP-Tablet\\Resources\\manifest.xml {{BRANCHNAME}} ${env.BRANCH_NAME} || EXIT /B 0"
// bat "fart.exe MP-Tablet\\Resources\\ChangeLog.html {{CURRENT-REL}} ${env.versionNumber} || EXIT /B 0"
// writeFile file: 'MP-Tablet\\changeLog.log', text: "${getChangeString()}"
// powershell '(Get-Content MP-Tablet\\Resources\\ChangeLog.html) | ForEach-Object { $_ -replace \"{{LAST-CHANGES}}\", \"${getChangeString()}\" } | Set-Content MP-Tablet\\Resources\\ChangeLog.html'
// // copio ed esporto in IIS02 i vari files .xml, .html, .zip
// bat "xcopy /y MP-Tablet\\Resources\\manifest.xml c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
// bat "xcopy /y MP-Tablet\\Resources\\ChangeLog.html c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
// bat "xcopy /y MP-Tablet\\Resources\\logoSteamware.png c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
// salvo copia della versione...
bat "xcopy /y MP-Tablet\\ReleaseClienti\\${env.BRANCH_NAME}\\* E:\\Staging\\byProd\\MP\\${env.BRANCH_NAME}\\MP-TAB\\${env.versionNumber}\\ "
@@ -259,8 +255,21 @@ pipeline {
}
}
@NonCPS
// Funzione x pubblicazione su server IIS di deploy
def publishToDeployServer(resourcesPath, iisPath) {
// manifest.xml: aggiorno versNumber ed URL del branch di update...
bat "fart.exe MP-Tablet\\Resources\\manifest.xml 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
bat "fart.exe MP-Tablet\\Resources\\manifest.xml {{BRANCHNAME}} ${env.BRANCH_NAME} || EXIT /B 0"
bat "fart.exe MP-Tablet\\Resources\\ChangeLog.html {{CURRENT-REL}} ${env.versionNumber} || EXIT /B 0"
writeFile file: 'MP-Tablet\\changeLog.log', text: "${getChangeString()}"
powershell '(Get-Content MP-Tablet\\Resources\\ChangeLog.html) | ForEach-Object { $_ -replace \"{{LAST-CHANGES}}\", \"${getChangeString()}\" } | Set-Content MP-Tablet\\Resources\\ChangeLog.html'
// copio ed esporto in IIS02 i vari files .xml, .html, .zip
bat "xcopy /y MP-Tablet\\Resources\\manifest.xml c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
bat "xcopy /y MP-Tablet\\Resources\\ChangeLog.html c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
bat "xcopy /y MP-Tablet\\Resources\\logoSteamware.png c:\\inetpub\\wwwroot\\SWS\\MAPO\\TAB\\${env.BRANCH_NAME}\\ "
}
// Funzione x recupero changeLog
def getChangeString() {
MAX_MSG_LEN = 100
def changeString = ""
@@ -281,10 +290,10 @@ def getChangeString() {
}
return changeString
}
// Funzione x invio email
def sendEmail(status) {
mail (
to: "$EMAIL_RECIPIENTS",
subject: "Build $BUILD_NUMBER - " + status + " ($JOB_NAME)",
body: "Modifiche:\n " + getChangeString() + "\n\n Verifica console output: $BUILD_URL/console" + "\n")
}
}