Files
SteamWare/Jenkinsfile
T
2018-10-19 11:16:17 +02:00

90 lines
3.0 KiB
Groovy

pipeline {
// Declarative Pipeline MODE con Scripted Pipeline Syntax entro le chiamate script { }
agent none
environment {
EMAIL_RECIPIENTS = 'samuele@steamware.net'
}
stages {
stage('Checkout') {
agent any
steps {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=623']) {
// env.versionNumber = VersionNumber(versionNumberString : '3.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '3.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'SteamWareLib'
}
}
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 SteamWareLib\\SteamWare.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
bat "e:\\nuget.exe restore ${WORKSPACE}\\SteamWare.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 SteamWareLib\\SteamWare.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
bat "e:\\nuget.exe restore ${WORKSPACE}\\SteamWare.sln"
}
script {
bat "\"${tool 'MSBuild-15.0'}\" SteamWareLib\\SteamWare.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
}
}
}
}
post {
success {
sendEmail("Successful")
}
failure {
sendEmail("Failed")
}
unstable {
sendEmail("Unstable")
}
}
}
@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: "Build $BUILD_NUMBER - " + status + " ($JOB_NAME)",
body: "Modifiche:\n " + getChangeString() + "\n\n Verifica console output: $BUILD_URL/console" + "\n")
}