From e476167a4d61c8647a5b8991c0ed8fd6a5976a3d Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Mon, 11 Feb 2019 16:55:53 +0100 Subject: [PATCH] Punto a sito 2 + test iniziale jenkinsfile... --- Jenkinsfile | 253 ++++++++++++++++++ .../PublishProfiles/OVH-Rigamonti.pubxml | 2 +- WebSCR/WebSCR.csproj.user | 2 +- WebSCR/bin/WebSCR.dll | Bin 72192 -> 72192 bytes 4 files changed, 255 insertions(+), 2 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..aeb9f74 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,253 @@ +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 { + /* build delle SteamWare libs! */ + /*build 'SteamWare/SteamWareLib'*/ + /* copio le libs...*/ + // mirroring directory x SteamWare Libs + // bat "robocopy /MIR ..\\..\\SteamWare\\SteamWareLib ..\\SteamWare\\SteamWareLib || EXIT /B 0" + + // 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=201']) { + // env.versionNumber = VersionNumber(versionNumberString : '2.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) + env.versionNumber = VersionNumber(versionNumberString : '2.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') + env.APP_NAME = 'WebSCR' + } + } + 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 "e:\\fart.exe VersGen\\VersGen.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0" + bat "e:\\nuget.exe restore ${WORKSPACE}\\WebSCR.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 "e:\\fart.exe VersGen\\VersGen.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0" + bat "e:\\nuget.exe restore ${WORKSPACE}\\WebSCR.sln" + } + script { + /* compilo installers in base al BRANCH del cliente... */ + if (env.BRANCH_NAME == "develop") { + parallel ( + ADM: { + sleep 5 + bat "\"${tool 'MSBuild-15.0'}\" ADM/ADM.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + }, + PUB: { + sleep 0 + bat "\"${tool 'MSBuild-15.0'}\" PUB/PUB.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 "e:\\fart.exe VersGen\\VersGen.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0" + // bat "e:\\nuget.exe restore ${WORKSPACE}\\WebSCR.sln" + // } + // script { + // /* DEPLOY condizionale: develop / master / demo_ovh */ + // if (env.BRANCH_NAME == "master") { + // parallel ( + // PUB_IIS01: { + // if(env.enableIIS01 == "Y") + // { + // 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.pubxml /p:VisualStudioVersion=15.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ PUB/PUB.csproj" + // } + // }, + // PUB_IIS02: { + // if(env.enableIIS02 == "Y") + // { + // 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.pubxml /p:VisualStudioVersion=15.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ PUB/PUB.csproj" + // } + // }, + // failFast: false) + // } + // if (env.BRANCH_NAME == "OVH") { + // parallel ( + // PUB_PROD: { + // 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=OVH-prod.pubxml /p:VisualStudioVersion=15.0 /p:RunCodeAnalysis=false /p:Configuration=OVH /p:username=WPROD01\\Steamware /p:Password=viaD@nte16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ PUB/PUB.csproj" + // }, + // failFast: false) + // } + // else { + // echo 'Nothing to deploy...' + // } + // } + // } + // } + // stage('Installers') { + // agent any + // steps { + // // in primis cambio versione e NuGet + // script { + // // CAMBIO numero versione + checkout NuGet in file sorgente!!! + // bat "e:\\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 in base al BRANCH del cliente... */ + // if (env.BRANCH_NAME == "master" || env.BRANCH_NAME.contains("DEMO") || env.BRANCH_NAME.contains("Giancarlo")) { + // echo 'Questo BRANCH non necessita di installer...' + // } + // else + // { + // parallel ( + // LANDING: { + // sleep 4 + // 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=${env.BRANCH_NAME} /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=15.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/ ADM/ADM.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "LAND") + // }, + // ADMIN: { + // sleep 0 + // 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=${env.BRANCH_NAME} /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=15.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/ PUB/PUB.csproj" + // // pubblico su server deploy! + // publishToDeployServer("MP-Admin\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "ADM") + // }, + // IO: { + // sleep 0 + // 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=${env.BRANCH_NAME} /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=15.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") + // }, + // MON: { + // sleep 3 + // 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=${env.BRANCH_NAME} /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=15.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: { + // 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=${env.BRANCH_NAME} /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=15.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") + // }, + // TABLET: { + // 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=${env.BRANCH_NAME} /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=15.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) + // } + // } + // } + // } + } + post { + success { + //sendEmail("Successful") + sendSlack("Successful", "good") + } + failure { + //sendEmail("Failed") + sendSlack("Failed", "danger") + } + unstable { + //sendEmail("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: "#webscr-dev", + 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" + ) +} \ No newline at end of file diff --git a/WebSCR/Properties/PublishProfiles/OVH-Rigamonti.pubxml b/WebSCR/Properties/PublishProfiles/OVH-Rigamonti.pubxml index de96820..c651b1e 100644 --- a/WebSCR/Properties/PublishProfiles/OVH-Rigamonti.pubxml +++ b/WebSCR/Properties/PublishProfiles/OVH-Rigamonti.pubxml @@ -12,7 +12,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt True True https://wprod01.steamware.net:8172/MsDeploy.axd - WebSCR/Rigamonti + WebSCR/Rigamonti2 False WMSVC diff --git a/WebSCR/WebSCR.csproj.user b/WebSCR/WebSCR.csproj.user index cb4add0..3aceeba 100644 --- a/WebSCR/WebSCR.csproj.user +++ b/WebSCR/WebSCR.csproj.user @@ -10,7 +10,7 @@ - Release|Any CPU + OVH|Any CPU diff --git a/WebSCR/bin/WebSCR.dll b/WebSCR/bin/WebSCR.dll index bd7a3d11ec96d4c5aa251ccb5fdee4f530416274..1e1cae9036e1e8fe10d468352de72ccfd72d2743 100644 GIT binary patch delta 110 zcmZqJ!qTvXWkLt@r_{v8?ycR7Cs_r~GEH&InmW;SN7t9MHz{uzwx_T$&f(Gls)%6# z0wy4qVPs&C&}U?j5M*Qs3U&#uypr+tbaA8O%y`>>LhCiAPuCG-3}N;U^O)W)$hdZ* M0n2t1A;vT80Kpw4g8%>k delta 122 zcmZqJ!qTvXWkLt@)U4RX?ycR7Cs_p+zi*D-;LPB&Mk4NmQ2DhD+f&#W=Wyvv$%>6( z00Jf;mSJRIkkDsjkPu{K2nu!y_H6$5@5L2chb?l2UbYLiotmyA$QU9Nl$w*8SezOY Zo|+Ww9Hdu}k~DpyAmgI#CPIv7*a1^BDYXCq