203 lines
8.3 KiB
Groovy
203 lines
8.3 KiB
Groovy
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=78']) {
|
|
// env.versionNumber = VersionNumber(versionNumberString : '1.2.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
|
env.versionNumber = VersionNumber(versionNumberString : '1.2.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
|
env.APP_NAME = 'ZCode'
|
|
}
|
|
}
|
|
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 ${WORKSPACE}\\VersGen\\VersGen.cs 0.0.0.0 ${env.versionNumber} || EXIT /B 0"
|
|
// checkout NuGet in file sorgente!!!
|
|
fixNuget("${WORKSPACE}\\ZebraCode.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 ${WORKSPACE}\\VersGen\\VersGen.cs 0.0.0.0 ${env.versionNumber} || EXIT /B 0"
|
|
fixNuget("${WORKSPACE}\\ZebraCode.sln")
|
|
}
|
|
script {
|
|
/* compilo installers in base al BRANCH del cliente... */
|
|
if (env.BRANCH_NAME == "develop") {
|
|
bat "\"${tool 'MSBuild-15.0'}\" ZCode\\ZCode.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
|
|
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=15.0 /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ ZCode\\ZCode.csproj"
|
|
}
|
|
}
|
|
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 ${WORKSPACE}\\VersGen\\VersGen.cs 0.0.0.0 ${env.versionNumber} || EXIT /B 0"
|
|
fixNuget("${WORKSPACE}\\ZebraCode.sln")
|
|
}
|
|
script {
|
|
/* DEPLOY condizionale: develop (Ufficio Seriate) / master (Sito Online) */
|
|
if (env.BRANCH_NAME == "master") {
|
|
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=15.0 /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ ZCode\\ZCode.csproj"
|
|
}
|
|
}
|
|
else if (env.BRANCH_NAME == "ovh") {
|
|
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/ ZCode\\ZCode.csproj"
|
|
}
|
|
else
|
|
{
|
|
echo 'Questo BRANCH non necessita di 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 ${WORKSPACE}\\VersGen\\VersGen.cs 0.0.0.0 ${env.versionNumber} || EXIT /B 0"
|
|
fixNuget("${WORKSPACE}\\ZebraCode.sln")
|
|
}
|
|
// ora mi occupo delle operazioni di compressione e copia...
|
|
script {
|
|
if (env.BRANCH_NAME == "stable" || env.BRANCH_NAME == "beta") {
|
|
// creo ZIP package
|
|
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=Release /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/ZCode.zip /p:DeployIisAppPath=\"Default Web Site/ZCode\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ ZCode/Zcode.csproj"
|
|
}
|
|
}
|
|
script {
|
|
// calcolo il config...
|
|
if (env.BRANCH_NAME.contains("beta")) {
|
|
env.config = "Debug"
|
|
env.classifier = "unstable"
|
|
}
|
|
else if (env.BRANCH_NAME == "stable") {
|
|
env.config = "Release"
|
|
env.classifier = ""
|
|
}
|
|
if (env.BRANCH_NAME == "stable" || env.BRANCH_NAME.contains("beta") ) {
|
|
// upload!
|
|
nexusArtifactUploader (
|
|
artifacts: [
|
|
[
|
|
artifactId: 'ZCode',
|
|
classifier: "${env.classifier}",
|
|
file: "ZCode\\ReleaseClienti\\${env.BRANCH_NAME}\\ZCode.zip",
|
|
type: 'zip'
|
|
]
|
|
],
|
|
credentialsId: 'bc9d8e92-4302-3266-817f-7b58501d12d5',
|
|
nexusUrl: 'nexus.steamware.net',
|
|
nexusVersion: 'nexus3',
|
|
protocol: 'http',
|
|
repository: 'SWS',
|
|
version: "${env.versionNumber}"
|
|
)
|
|
}
|
|
else
|
|
{
|
|
echo 'Questo BRANCH non necessita di installers...'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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 slack
|
|
def sendSlack(status, colorCode) {
|
|
slackSend (
|
|
color: colorCode,
|
|
channel: "#qrc-utils-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"
|
|
)
|
|
}
|
|
|
|
// funzione x fix pacchetti nuget da NOSTRO repo Nexus con proxy
|
|
def fixNuget(solutionFile) {
|
|
// bat "e:\\nuget setapikey fe387daa-d07c-3207-877e-96c8be1be91b -source http://nexus.steamware.net/repository/nuget-group"
|
|
// solo la prima volta va aggiunta...
|
|
hasSource = bat "e:\\nuget sources list | find \"Steamware\" /C"
|
|
if (hasSource == "0")
|
|
{
|
|
bat "e:\\nuget sources Add -Name \"Steamware Nexus\" -Source http://nexus.steamware.net/repository/nuget-group -username \"nugetUser\" -password \"viaDante16\""
|
|
}
|
|
else
|
|
{
|
|
bat "e:\\nuget sources Update -Name \"Steamware Nexus\" -Source http://nexus.steamware.net/repository/nuget-group -username \"nugetUser\" -password \"viaDante16\""
|
|
}
|
|
bat "e:\\nuget.exe restore ${solutionFile}"
|
|
} |