forked from junian/Standard.Licensing
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
148 lines (146 loc) · 5.57 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
* Copyright Moody's Analytics.
*/
@NonCPS
def isJobStartedByTimer() {
try {
for ( buildCause in currentBuild.getBuildCauses() ) {
if (buildCause != null) {
if (buildCause.shortDescription.contains("Started by timer")) {
echo "build started by timer"
return true
}
}
}
} catch(theError) {
echo "Error getting build cause: ${theError}"
}
return false
}
def isJobStartedByScm() {
try {
for ( buildCause in currentBuild.getBuildCauses() ) {
if (buildCause != null) {
if (buildCause.shortDescription.contains("Started by an SCM change")) {
echo "build Started by an SCM change"
return true
}
}
}
} catch(theError) {
echo "Error getting build cause: ${theError}"
}
return false
}
def isJobStartedByUser() {
try {
for ( buildCause in currentBuild.getBuildCauses() ) {
if (buildCause != null) {
if (buildCause.shortDescription.contains("Started by user")) {
echo "build Started by user"
return true
}
}
}
} catch(theError) {
echo "Error getting build cause: ${theError}"
}
return false
}
def isJobStartedByIndexing() {
try {
for ( buildCause in currentBuild.getBuildCauses() ) {
if (buildCause != null) {
if (buildCause.shortDescription.contains("Branch indexing")) {
echo "Branch indexing"
return true
}
}
}
} catch(theError) {
echo "Error getting build cause: ${theError}"
}
return false
}
def isTimerBuild = isJobStartedByTimer()
def isScmBuild = isJobStartedByScm()
def isUserBuild = isJobStartedByUser()
def isBranchIndexingBuild = isJobStartedByIndexing()
def versionAffix = "21_41_0";
def moodysDatabase = "moodys_cl_${versionAffix}";
def moodysUsername = "moodys_cl_${versionAffix}";
def moodysPassword = "a";
pipeline {
triggers {
cron 'H H(0-2) * * *'
pollSCM('H/5 * * * *')
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
timestamps()
}
agent {label 'windows'}
environment {
NUGET_PACKAGES = "${env.WORKSPACE}\\ng-cache"
NUGET_HTTP_CACHE_PATH = "${env.WORKSPACE}\\http-cache"
}
stages {
stage ('Build') {
when {
expression {
isScmBuild == true || isUserBuild == true || isBranchIndexingBuild == false
}
}
steps {
script {
def msbuild = tool name: 'msbuild', type: 'hudson.plugins.msbuild.MsBuildInstallation'
if (isUnix()) {
sh """
${msbuild} Core.msbuild /p:NugetServer=http://sf1-wbroci101.analytics.moodys.net/NuGet/ /p:SkipCoverage=false /p:WarningLevel=0 /p:Configuration=Release /p:DebugSymbols=false /p:DebugType=none /p:Optimize=true
"""
} else {
powershell """
git submodule update --init
\$VERSION = Get-Content 'version' -TotalCount 1
\$PACKAGE_VERSION = "\$VERSION"
Write-Output "Generating Package with version: \$PACKAGE_VERSION ..."
dotnet pack 'src\\Standard.Licensing.sln' -o dist /p:DebugSymbols=false /p:DebugType=none /p:Optimize=true -p:Configuration=Release -p:Version=\$VERSION -p:PackageVersion=\$PACKAGE_VERSION
dotnet nuget push dist\\*.nupkg --source http://sf1-wbroci101.analytics.moodys.net/NuGet/
"""
}
}
}
}
stage ('success'){
steps {
script {
currentBuild.result = 'SUCCESS'
}
}
}
}
post {
failure {
emailext(
body: '${SCRIPT, template="jenkins-html-email.template"}',
mimeType: 'text/html',
recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'DevelopersRecipientProvider']],
subject: '${DEFAULT_SUBJECT}',
to: '[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected]')
script {
currentBuild.result = 'FAILURE'
}
}
success {
emailext(
body: '${SCRIPT, template="jenkins-html-email.template"}',
mimeType: 'text/html',
recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'DevelopersRecipientProvider']],
subject: '${DEFAULT_SUBJECT}',
to: '[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected]')
xunit([xUnitDotNet(deleteOutputFiles: true, failIfNotNew: true, pattern: '**/**/xunit-results.xml', skipNoTestFiles: true, stopProcessingIfError: false)])
publishHTML([allowMissing: true, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '', reportFiles: 'index.htm', reportName: 'Code Coverage Report', reportTitles: ''])
}
}
}