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=593']) { // env.versionNumber = VersionNumber(versionNumberString : '${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO' } } script { currentBuild.displayName = "${env.versionNumber}" if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME.contains("DEMO") || env.BRANCH_NAME.contains("TEST")) { currentBuild.description = "TEST ${env.versionNumber}" } else { currentBuild.description = "BUILD ${env.versionNumber}" } } /* CAMBIO numero versione in file sorgente!!! */ bat "fart.exe VersGen\\VersGen.cs 000.000 ${env.versionNumber} || EXIT /B 0" } } stage('Build') { agent any steps { script { /* compilo installers in base al BRANCH del cliente... */ if (env.BRANCH_NAME == "develop") { /* CAMBIO numero versione in file sorgente!!! */ bat "fart.exe VersGen\\VersGen.cs 000.000 ${env.versionNumber} || EXIT /B 0" bat "e:\\nuget.exe restore ${WORKSPACE}\\WebGIM.sln" parallel ( WEBGIM: { bat "\"${tool 'MSBuild-15.0'}\" GIM_site/GIM_site.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" }, failFast: false) } else { echo 'Nothing to Build...' } } } } stage('Test') { steps { echo 'Testing.. 2 be done...' } } stage('Deploy') { agent any steps { script { /* DEPLOY condizionale: develop / master */ if (env.BRANCH_NAME == "master") { /* CAMBIO numero versione in file sorgente!!! */ bat "fart.exe VersGen\\VersGen.cs 000.000 ${env.versionNumber} || EXIT /B 0" bat "e:\\nuget.exe restore ${WORKSPACE}\\WebGIM.sln" parallel ( IIS01: { 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/ GIM_site/GIM_site.csproj" }, IIS02: { 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/ GIM_site/GIM_site.csproj" }, failFast: false) } else { echo 'Nothing to deploy...' } } } } stage('RemoteDeploy') { agent any steps { script { /* compilo installers in base al BRANCH del cliente... */ if (env.BRANCH_NAME == "ALUMAT-TEST") { /* CAMBIO numero versione in file sorgente!!! */ bat "fart.exe VersGen\\VersGen.cs 000.000 ${env.versionNumber} || EXIT /B 0" bat "e:\\nuget.exe restore ${WORKSPACE}\\WebGIM.sln" parallel ( PIC: { 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=Alumat-TEST.pubxml /p:VisualStudioVersion=15.0 /p:RunCodeAnalysis=false /p:Configuration=PROD-OVH /p:username=WPROD01\\Steamware /p:Password=viaD@nte16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ GIM_site/GIM_site.csproj" }, failFast: false) } else if (env.BRANCH_NAME == "ALUMAT-PROD") { /* CAMBIO numero versione in file sorgente!!! */ bat "fart.exe VersGen\\VersGen.cs 000.000 ${env.versionNumber} || EXIT /B 0" bat "e:\\nuget.exe restore ${WORKSPACE}\\WebGIM.sln" parallel ( PIC: { 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=Alumat-PROD.pubxml /p:VisualStudioVersion=15.0 /p:RunCodeAnalysis=false /p:Configuration=DEMO-OVH /p:username=WPROD01\\Steamware /p:Password=viaD@nte16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ GIM_site/GIM_site.csproj" }, failFast: false) } else{ echo 'Questo BRANCH non necessita di RemoteDeploy...' } } } } stage('Installers') {agent any steps { script { /* compilo installers in base al BRANCH del cliente... */ if (env.BRANCH_NAME == "SOMASCHINI-PROD") { /* CAMBIO numero versione in file sorgente!!! */ bat "fart.exe VersGen\\VersGen.cs 000.000 ${env.versionNumber} || EXIT /B 0" bat "e:\\nuget.exe restore ${WORKSPACE}\\WebGIM.sln" parallel ( PIC: { 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=Somaschini /p:PublishProfile=Somaschini-ITA.pubxml /p:VisualStudioVersion=15.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/SomaschiniITA/${env.versionNumber}/WebGIM.zip /p:DeployIisAppPath=\"Default Web Site/WebGIM\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ GIM_site/GIM_site.csproj" bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GIM_site\\ReleaseClienti\\SomaschiniITA\" \"E:\\Staging\\byProd\\WebGIM\\SomaschiniITA\" " bat "E:\\Jenkins\\exportDropbox.bat \"${WORKSPACE}\\GIM_site\\ReleaseClienti\\SomaschiniITA\" \"E:\\Staging\\WebGIM\\SomaschiniITA\" " // dropbox configName: 'Donati', remoteDirectory: 'installers/MP-LAND', removePrefix: 'ReleaseClienti/Donati', sourceFiles: 'ReleaseClienti/Donati/**' }, failFast: false) } else{ echo 'Questo BRANCH non necessita di Installers...' } } } } /*stage('Archive') { steps { echo 'Archiviazione build Release' archiveArtifacts artifacts: 'ScratchTest/ScratchTest/bin/Release/**' } }*/ } post { success { mail to:"samuele@steamware.net", subject:"SUCCESS: ${currentBuild.fullDisplayName}", body: "Build passed." } failure { mail to:"samuele@steamware.net", subject:"FAILURE: ${currentBuild.fullDisplayName}", body: "Build failed." } unstable { mail to:"samuele@steamware.net", subject:"UNSTABLE: ${currentBuild.fullDisplayName}", body: "Build is unstable." } } }