From 39f773deacb70ae953409e2f4111b30a1629d7c4 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Sat, 6 Apr 2019 17:27:54 +0200 Subject: [PATCH] Aggiunto jenkinsfile --- Jenkinsfile | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..83518bd --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,262 @@ +pipeline { + // Declarative Pipeline MODE con Scripted Pipeline Syntax entro le chiamate script { } + agent none + environment { + EMAIL_RECIPIENTS = 'samuele@steamware.net' + // enableIIS01 = 'Y' + // enableIIS02 = 'Y' + } + stages { + stage('Checkout') { + agent any + steps { + + /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ + script { + withEnv(['NEXT_BUILD_NUMBER=1']) { + env.versionNumber = VersionNumber(versionNumberString : '0.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-04-01', skipFailedBuilds: true) + // env.versionNumber = VersionNumber(versionNumberString : '0.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2019-04-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') + env.APP_NAME = 'MpMonVue' + } + } + script { + currentBuild.displayName = "${env.versionNumber}" + if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME.contains("DEMO")) { + currentBuild.description = "TEST ${env.versionNumber}" + } + else { + currentBuild.description = "BUILD ${env.versionNumber}" + } + } + // // 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 { + // 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") { + // parallel ( + // ADM_IO: { + // sleep 2 + // bat "\"${tool 'MSBuild-15.0'}\" MP-ADM/MP-ADM.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + // bat "\"${tool 'MSBuild-15.0'}\" MP-IO/MP-IO.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + // }, + // LAND_MON: { + // sleep 4 + // bat "\"${tool 'MSBuild-15.0'}\" MP-LAND/MP-LAND.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + // bat "\"${tool 'MSBuild-15.0'}\" MP-MON/MP-MON.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + // }, + // SITE_TAB: { + // sleep 0 + // bat "\"${tool 'MSBuild-15.0'}\" MP-SITE/MP-SITE.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + // bat "\"${tool 'MSBuild-15.0'}\" MP-TAB/MP-TAB.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + // }, + // failFast: false) + // } + // else { + // echo 'Niente x Build (limitata a develop)...' + // } + // } + // } + // } + // 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: master (Ufficio Seriate) / demo_ovh (Demo Online) */ + // if (env.BRANCH_NAME == "master") { + // parallel ( + // ADM_IO: { + // sleep 2 + // if(env.enableIIS01 == "Y") + // { + // // ADM + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-ADM/MP-ADM.csproj" + // // IO + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-IO/MP-IO.csproj" + // } + // if(env.enableIIS02 == "Y") + // { + // // ADM + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-ADM/MP-ADM.csproj" + // // IO + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-IO/MP-IO.csproj" + // } + // }, + // LAND_MON: { + // sleep 4 + // if(env.enableIIS02 == "Y") + // { + // //LAND + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-LAND/MP-LAND.csproj" + // // MON + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-MON/MP-MON.csproj" + // } + // if(env.enableIIS01 == "Y") + // { + // // LAND + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-LAND/MP-LAND.csproj" + // // MON + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-MON/MP-MON.csproj" + // } + // }, + // SITE_TAB: { + // sleep 0 + // if(env.enableIIS01 == "Y") + // { + // // SITE + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-SITE/MP-SITE.csproj" + // // TAB + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-TAB/MP-TAB.csproj" + // } + // if(env.enableIIS02 == "Y") + // { + // // SITE + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-SITE/MP-SITE.csproj" + // // TAB + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-TAB/MP-TAB.csproj" + // } + // }, + // failFast: false) + // } + // if (env.BRANCH_NAME == "OVH-DEMO") { + // parallel ( + // // da fare!!! + // failFast: false) + // } + // else { + // echo 'Nothing to deploy...' + // } + // } + // } + // } + // stage('Installers') { + // // da rivedere: creare branch = versioni LEGACY, STABLE (LTS), INSIDER (ULTIMATE), e NON pubblicare DOCS (ex branch Giancarlo)... impostare filtro? + // agent any + // steps { + // // in primis cambio versione e NuGet + // 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" + // } + // // ora mi occupo delle operazioni di compressione e copia... + // script { + // /* compilo installers SOLO stable / beta */ + // if (env.BRANCH_NAME == "stable" || env.BRANCH_NAME.contains("beta") ) { + // parallel ( + // ADM_IO: { + // sleep 2 + // // ADM + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/ADM.zip /p:DeployIisAppPath=\"Default Web Site/MP/ADM\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-ADM/MP-ADM.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP-ADM\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "ADM") + // // IO + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/IO.zip /p:DeployIisAppPath=\"Default Web Site/MP/IO\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-IO/MP-IO.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP-IO\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "IO") + // }, + // LAND_MON: { + // sleep 4 + // // LAND + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/LAND.zip /p:DeployIisAppPath=\"Default Web Site/MP/LAND\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-LAND/MP-LAND.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP-LAND\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "LAND") + // // MON + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/MON.zip /p:DeployIisAppPath=\"Default Web Site/MP/MON\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-MON/MP-MON.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP-MON\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "MON") + // }, + // SITE_TAB: { + // sleep 0 + // // SITE + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/SITE.zip /p:DeployIisAppPath=\"Default Web Site/MP/SITE\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-SITE/MP-SITE.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP-SITE\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "SITE") + // // TAB + // sleep 2 + // bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/TAB.zip /p:DeployIisAppPath=\"Default Web Site/MP/TAB\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-TAB/MP-TAB.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP-TAB\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "TAB") + // }, + // failFast: false) + // } + // else + // { + // echo 'Questo BRANCH non necessita di installer...' + // } + // } + // } + // } + // } + post { + success { + sendSlack("Successful", "good") + } + failure { + sendSlack("Failed", "danger") + } + unstable { + sendSlack("Unstable", "warning") + } + } +} + + +@NonCPS +// Funzione x recupero changeLog +def getChangeString() { + MAX_MSG_LEN = 100 + def changeString = "" + + echo "Gathering SCM changes" + def changeLogSets = currentBuild.changeSets + for (int i = 0; i < changeLogSets.size(); i++) { + def entries = changeLogSets[i].items + for (int j = 0; j < entries.length; j++) { + def entry = entries[j] + truncated_msg = entry.msg.take(MAX_MSG_LEN) + changeString += " - ${truncated_msg} [${entry.author}]\n" + } + } + + if (!changeString) { + changeString = " - Nessuna Modifica" + } + return changeString +} + +// Funzione x invio email +def sendEmail(status) { + mail ( + to: "$EMAIL_RECIPIENTS", + subject: "${env.versionNumber} " + status +": Build $BUILD_NUMBER ($JOB_NAME)", + body: "Modifiche:\n " + getChangeString() + "\n\n Verifica console output: $BUILD_URL/console" + "\n" + ) +} + +// Funzione x invio slack +def sendSlack(status, colorCode) { + slackSend ( + color: colorCode, + channel: "#mapo-dev", + failOnError: false, + message: "${env.JOB_NAME} ${env.versionNumber} | " + status + ": Build ${env.BUILD_NUMBER}\n\n" + + "Modifiche:\n " + getChangeString() + "\n\n Verifica build: <${env.BUILD_URL}|Apri>" + "\n" + ) +}