pipeline { agent none stages { stage('Checkout') { agent any steps { /* build delle SteamWare libs! */ // build 'SteamWare/SteamWareLib' /* copio le libs...*/ // step([$class: 'CopyArtifact', fingerprintArtifacts: true, projectName: 'Steamware/SteamWareLib', selector: [$class: 'WorkspaceSelector'], target: '../Steamware/SteamWareLib']) /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { withEnv(['NEXT_BUILD_NUMBER=2139']) { // impiego numero di build del SINGOLO RAMO // env.versionNumber = VersionNumber(versionNumberString : '4.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) // forzo numero di build x tutti rami uguali env.versionNumber = VersionNumber(versionNumberString : '4.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'GMW' } } 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}" } } } } stage('Build') { agent any steps { // CAMBIO numero versione in file sorgente + recupero packages bat "e:\\fart.exe ${WORKSPACE}\\VersGen\\GMW.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0" bat "e:\\nuget.exe restore ${WORKSPACE}\\GMW_Data.sln" bat "e:\\nuget.exe restore ${WORKSPACE}\\GMW.sln" bat "e:\\nuget.exe restore ${WORKSPACE}\\GMW_Terminus.sln" script { /* compilo installers in base al BRANCH del cliente... */ if (env.BRANCH_NAME == "develop") { parallel ( GMW: { sleep 0 bat "\"${tool 'MSBuild-15.0'}\" GMW/GMW.csproj -verbosity:m -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" }, GMWT: { sleep 1 bat "\"${tool 'MSBuild-15.0'}\" GMW_Term/GMW_Term.csproj -verbosity:m -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" }, failFast: false) } else { echo 'Nothing to Build...' } } } } stage('Test') { steps { script { /* compilo installers in base al BRANCH del cliente... */ parallel ( GMW: { sleep 0 // bat "\"${tool 'MSBuild-15.0'}\" GMW/GMW.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" echo 'Testing.. 2 be done...' }, GMWT: { sleep 1 // bat "\"${tool 'MSBuild-15.0'}\" GMW_Term/GMW_Term.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" echo 'Testing.. 2 be done...' }, failFast: false) } } } stage('Deploy-Installers') { agent any steps { // CAMBIO numero versione in file sorgente + recupero packages bat "e:\\fart.exe ${WORKSPACE}\\VersGen\\GMW.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0" bat "e:\\nuget.exe restore ${WORKSPACE}\\GMW_Data.sln" bat "e:\\nuget.exe restore ${WORKSPACE}\\GMW.sln" bat "e:\\nuget.exe restore ${WORKSPACE}\\GMW_Terminus.sln" script { /* DEPLOY condizionale: develop / master */ if (env.BRANCH_NAME == "develop") { parallel ( GMW_TK: { sleep 0 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_TK.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02_TK /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" }, GMW_SP: { sleep 1 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_SP.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02_SP /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" }, failFast: false) parallel ( GMWT_TK: { sleep 2 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_TK.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02_TK /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" }, GMWT_SP: { sleep 3 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_SP.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02_SP /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" }, failFast: false) } else if (env.BRANCH_NAME == "TK_GMW") { parallel ( GMW_TK: { sleep 0 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_TK.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01_TK /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" }, TEST: { sleep 1 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=TK_test /p:PublishProfile=TK_test.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/TK_test/Build_${env.versionNumber}/GMW.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\TK_test\" \"E:\\Staging\\byProd\\GMW\\TK_test\\GMW-site\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\TK_test\" \"E:\\Staging\\GMW\\GMW-site\\TK_test\" " dropbox configName: 'Mazzucconi - Tekal', remoteDirectory: 'File_Installazione_GMW_Test', removePrefix: 'GMW/ReleaseClienti/TK_test', sourceFiles: 'GMW/ReleaseClienti/TK_test/**' }, PROD: { 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=TK_prod /p:PublishProfile=TK_prod.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/TK_prod/Build_${env.versionNumber}/GMW.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\TK_prod\" \"E:\\Staging\\byProd\\GMW\\TK_prod\\GMW-site\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\TK_prod\" \"E:\\Staging\\GMW\\GMW-site\\TK_prod\" " dropbox configName: 'Mazzucconi - Tekal', remoteDirectory: 'File_Installazione_GMW', removePrefix: 'GMW/ReleaseClienti/TK_prod', sourceFiles: 'GMW/ReleaseClienti/TK_prod/**' }, failFast: false) } else if (env.BRANCH_NAME == "TK_GMWT") { parallel ( GMW_TK: { sleep 0 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_TK.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01_TK /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" }, TEST: { sleep 1 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=TK_test /p:PublishProfile=TK_test.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/TK_test/Build_${env.versionNumber}/GMWT.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\TK_test\" \"E:\\Staging\\byProd\\GMWT\\TK_test\\GMWT\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\TK_test\" \"E:\\Staging\\GMW\\GMWT\\TK_test\" " dropbox configName: 'Mazzucconi - Tekal', remoteDirectory: 'File_Installazione_GMWT_Test', removePrefix: 'GMW_Term/ReleaseClienti/TK_test', sourceFiles: 'GMW_Term/ReleaseClienti/TK_test/**' }, PROD: { 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=TK_prod /p:PublishProfile=TK_prod.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/TK_prod/Build_${env.versionNumber}/GMWT.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\TK_prod\" \"E:\\Staging\\byProd\\GMWT\\TK_prod\\GMWT\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\TK_prod\" \"E:\\Staging\\GMW\\GMWT\\TK_prod\" " dropbox configName: 'Mazzucconi - Tekal', remoteDirectory: 'File_Installazione_GMWT', removePrefix: 'GMW_Term/ReleaseClienti/TK_prod', sourceFiles: 'GMW_Term/ReleaseClienti/TK_prod/**' }, failFast: false) } else if (env.BRANCH_NAME == "SP_GMW") { parallel ( GMW_SP: { sleep 0 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_SP.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01_SP /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" }, TEST: { sleep 1 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=SP_test /p:PublishProfile=SP_test.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/SP_test/Build_${env.versionNumber}/GMW.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\SP_test\" \"E:\\Staging\\byProd\\GMW\\SP_test\\GMW-site\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\SP_test\" \"E:\\Staging\\GMW\\GMW-site\\SP_test\" " dropbox configName: 'Mazzucconi - San Possidonio', remoteDirectory: 'File_Installazione_GMW_Test', removePrefix: 'GMW/ReleaseClienti/SP_test', sourceFiles: 'GMW/ReleaseClienti/SP_test/**' }, PROD: { 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=SP_prod /p:PublishProfile=SP_prod.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/SP_prod/Build_${env.versionNumber}/GMW.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW/GMW.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\SP_prod\" \"E:\\Staging\\byProd\\GMW\\SP_prod\\GMW-site\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW\\ReleaseClienti\\SP_prod\" \"E:\\Staging\\GMW\\GMW-site\\SP_prod\" " dropbox configName: 'Mazzucconi - San Possidonio', remoteDirectory: 'File_Installazione_GMW', removePrefix: 'GMW/ReleaseClienti/SP_prod', sourceFiles: 'GMW/ReleaseClienti/SP_prod/**' }, failFast: false) } else if (env.BRANCH_NAME == "SP_GMWT") { parallel ( GMW_SP: { sleep 0 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_SP.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01_SP /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" }, TEST: { sleep 1 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=SP_test /p:PublishProfile=SP_test.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/SP_test/Build_${env.versionNumber}/GMWT.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\SP_test\" \"E:\\Staging\\byProd\\GMWT\\SP_test\\GMWT\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\SP_test\" \"E:\\Staging\\GMW\\GMWT\\SP_test\" " dropbox configName: 'Mazzucconi - San Possidonio', remoteDirectory: 'File_Installazione_GMWT_Test', removePrefix: 'GMW_Term/ReleaseClienti/SP_test', sourceFiles: 'GMW_Term/ReleaseClienti/SP_test/**' }, PROD: { 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=SP_prod /p:PublishProfile=SP_prod.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/SP_prod/Build_${env.versionNumber}/GMWT.zip /p:PackageAsSingleFile=True /p:OutputPath=bin/ -verbosity:m GMW_Term/GMW_Term.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\SP_prod\" \"E:\\Staging\\byProd\\GMWT\\SP_prod\\GMW-site\" " // bat "E:\\Jenkins\\exportInstaller.bat \"${WORKSPACE}\\GMW_Term\\ReleaseClienti\\SP_prod\" \"E:\\Staging\\GMW\\GMWT\\SP_prod\" " dropbox configName: 'Mazzucconi - San Possidonio', remoteDirectory: 'File_Installazione_GMWT_Test', removePrefix: 'GMW_Term/ReleaseClienti/SP_prod', sourceFiles: 'GMW_Term/ReleaseClienti/SP_prod/**' }, failFast: false) } else { echo 'Niente x Deploy / Install...' } } } } } post { success { sendSlack("Successful", "good") } failure { sendSlack("Failed", "danger") } unstable { sendSlack("Unstable", "warning") } } } // // Funzione x pubblicazione su server IIS di deploy // def publishToDeployServer(prjPath, iisPath, packName) { // echo "Richiesto esecuzione publishToDeployServer con parametri: " + prjPath + " | " + iisPath + " | " + packName // // inizio copiando files di base da area VersGen... // bat "xcopy /y VersGen\\ChangeLog.html " + prjPath + "Resources\\ChangeLog.html " // bat "xcopy /y VersGen\\logoSteamware.png " + prjPath + "Resources\\logoSteamware.png " // bat "xcopy /y VersGen\\manifest.xml " + prjPath + "Resources\\manifest.xml " // // manifest.xml: aggiorno versNumber ed URL del branch di update... // bat "e:\\fart.exe " + prjPath + "Resources\\manifest.xml 1.0.0.0 ${env.versionNumber} || EXIT /B 0" // bat "e:\\fart.exe " + prjPath + "Resources\\manifest.xml {{BRANCHNAME}} ${env.BRANCH_NAME} || EXIT /B 0" // bat "e:\\fart.exe " + prjPath + "Resources\\manifest.xml {{PACKNAME}} " + packName + " || EXIT /B 0" // bat "e:\\fart.exe " + prjPath + "Resources\\ChangeLog.html {{CURRENT-REL}} ${env.versionNumber} || EXIT /B 0" // writeFile file: prjPath + 'changeLog.log', text: "${getChangeString()}" // powershell '(Get-Content ' + prjPath + 'Resources\\ChangeLog.html) | ForEach-Object { $_ -replace \"{{LAST-CHANGES}}\", \"${getChangeString()}\" } | Set-Content ' + prjPath + 'Resources\\ChangeLog.html' // // copio ed esporto in IIS02 i vari files .xml, .html, .zip // bat "xcopy /y " + prjPath + "Resources\\manifest.xml " + iisPath + packName + "\\${env.BRANCH_NAME}\\ " // bat "xcopy /y " + prjPath + "Resources\\ChangeLog.html " + iisPath + packName + "\\${env.BRANCH_NAME}\\ " // bat "xcopy /y " + prjPath + "Resources\\logoSteamware.png " + iisPath + packName + "\\${env.BRANCH_NAME}\\ " // // salvo copia della versione... // bat "xcopy /y " + prjPath + "\\ReleaseClienti\\${env.BRANCH_NAME}\\* E:\\Staging\\byProd\\MP\\${env.BRANCH_NAME}\\" + packName + "\\${env.versionNumber}\\ " // // copio x AutoUpdate deploy // bat "xcopy /y " + prjPath + "\\ReleaseClienti\\${env.BRANCH_NAME}\\" + packName + ".zip " + iisPath + packName + "\\${env.BRANCH_NAME}\\ " // } @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: "#gmw-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" ) }