Inserito jenkisfile (da testare!!!)

This commit is contained in:
Samuele E. Locatelli
2019-10-09 16:26:46 +02:00
parent 8d8940f4ea
commit b84736f4f5
2 changed files with 188 additions and 2 deletions
Vendored
+186
View File
@@ -0,0 +1,186 @@
pipeline {
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=133']) {
// 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 = 'MConnectSDK'
}
}
script {
currentBuild.displayName = "${env.versionNumber}"
if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME.contains("DEMO") || env.BRANCH_NAME.contains("UnitTesting")) {
currentBuild.description = "TEST ${env.versionNumber}"
}
else {
currentBuild.description = "BUILD ${env.versionNumber}"
}
}
/* CAMBIO numero versione in file sorgente!!! */
bat "e:\\fart.exe SharedAssemblyInfo.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
}
}
stage('Build') {
agent any
steps {
script {
// calcolo il config...
if (env.BRANCH_NAME == "develop") {
env.config = "Debug"
}
else if (env.BRANCH_NAME == "master") {
env.config = "Release"
}
// compilo installers in base al BRANCH...
if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME == "master") {
// CAMBIO numero versione in file sorgente!!!
bat "e:\\fart.exe SharedAssemblyInfo.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// restore nuget packages
bat "e:\\nuget.exe restore ${WORKSPACE}\\MConnect.sln"
// BUILD Develop (della sola libreria)!
bat "\"${tool 'MSBuild-16.0'}\" MConnectSDK/MConnectSDK.csproj -target:Build /p:Configuration=${env.config} /p:Platform=\"x86\" /p:OutputPath=bin/${env.config}/ /m"
}
else {
echo 'NON faccio test di Build se non per BRANCH DEVELOP...'
}
}
}
}
stage('Test') {
steps {
echo 'Testing.. 2 be done...'
}
}
stage('Deploy') {
agent any
steps {
// in primis compilo a seconda del branch... TUTTO tranne develop...
script {
// calcolo il config...
if (env.BRANCH_NAME == "develop") {
env.config = "Debug"
env.classifier = "unstable"
}
else if (env.BRANCH_NAME == "master") {
env.config = "Release"
env.classifier = ""
}
// procedo solo se NON si tratta di commit in ramo UnitTesting...
if (env.BRANCH_NAME != "UnitTesting") {
// CAMBIO numero versione in file sorgente!!!
bat "e:\\fart.exe SharedAssemblyInfo.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// restore nuget packages
bat "e:\\nuget.exe restore ${WORKSPACE}\\MConnect.sln"
// BUILD!
bat "\"${tool 'MSBuild-16.0'}\" MConnectSDK/MConnectSDK.csproj -target:Build /p:Configuration=${env.config} /p:Platform=\"x86\" /p:OutputPath=bin/ /m"
// creo package NuGet...
cd "Rilasci"
bat "e:\\nuget.exe pack ${WORKSPACE}\\MConnectSDK\\MConnectSDK.csproj -properties Configuration=Release"
}
else
{
echo 'Nessun Deploy x UnitTesting'
}
}
// ora mi occupo delle operazioni di invio a NEXUS...
script {
if (env.BRANCH_NAME == "develop") {
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: 'nexus.steamware.net',
//groupId: 'SOUR',
version: "${env.versionNumber}",
repository: 'nuget-hosted',
credentialsId: 'bc9d8e92-4302-3266-817f-7b58501d12d5',
artifacts: [
[artifactId: 'MConnectSDK',
classifier: "${env.classifier}",
file: "Rilasci\\MConnectSDK.${env.versionNumber}.nupkg",
type: 'nupkg']
]
)
}
else if (env.BRANCH_NAME == "master") {
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'https',
nexusUrl: 'repository.scmgroup.com',
//groupId: 'SOUR',
version: "${env.versionNumber}",
repository: 'mconnect-nuget',
credentialsId: 'b1dcea22-0d35-4092-80a1-973e6be41c78',
artifacts: [
[artifactId: 'MConnectSDK',
classifier: "${env.classifier}",
file: "Rilasci\\MConnectSDK.${env.versionNumber}.nupkg",
type: 'nupkg']
]
)
}
}
}
}
}
post {
success {
sendSlack("Successful", "good")
}
failure {
sendSlack("Failed", "danger")
}
unstable {
sendSlack("Unstable", "warning")
}
}
}
@NonCPS
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
}
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")
}
// Funzione x invio slack
def sendSlack(status, colorCode) {
slackSend (
color: colorCode,
channel: "#MConnectSDK-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"
)
}
+2 -2
View File
@@ -8,5 +8,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © Steamware 2019")]
[assembly: AssemblyTrademark("_")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.1.1910.133")]
[assembly: AssemblyFileVersion("1.1.1910.133")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]