This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
forked from eventuate-tram/eventuate-tram-core-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
92 lines (73 loc) · 2.77 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
node('docker-builds-slave') {
def slackChannel = '#media-management-alerts'
library identifier: "${env.DEFAULT_SHARED_LIBS}",
retriever: modernSCM([$class: 'GitSCMSource', remote: "${env.DEFAULT_SHARED_LIBS_REPO}"])
pipelineProps.defaultBuildMultibranchProperties();
def sdkDotnetBaseImage = 'mcr.microsoft.com/dotnet/core/sdk:3.0.100'
def imageEnvVar = "-e HOME='/tmp' -e DOTNET_ROLL_FORWARD='Major' -e DOTNET_CLI_TELEMETRY_OPTOUT=1"
try {
stage('Checkout') {
logger.stage()
timeout(10) {
checkout scm
}
slackUtils.notifyBuild('STARTED', slackChannel)
}
def nextVersion
stage("Build Release") {
docker.image(sdkDotnetBaseImage).inside(imageEnvVar) {
sh "dotnet build -c Release"
}
}
stage("Release Notes") {
logger.stage()
withVault(vaultSecrets: [
[path: "jenkins/mediamanagement/services/github", secretValues: [[vaultKey: 'publish_token', envVar: 'GITHUB_TOKEN'], [vaultKey: 'user', envVar: 'GITHUB_USER']]],
[path: "jenkins/mediamanagement/services/nexus_npm_settings", secretValues: [[vaultKey: 'file', envVar: 'npm_settings']]]
]) {
def nodeTool = "Node 12.16.0"
nodejs(nodeTool) {
sh """cat > $WORKSPACE/.npmrc << EOL\n$npm_settings\nEOL"""
sh "npm ci"
sh "npm run semantic-release"
}
}
if (fileExists('semantic-release.log')) {
def lines = readFile('semantic-release.log').readLines()
nextVersion = lines[0]
}
}
if (nextVersion) {
stage("Pack Nuget") {
logger.stage()
docker.image(sdkDotnetBaseImage).inside(imageEnvVar) {
sh "dotnet pack -c Release -p:Version=${nextVersion}"
}
}
stage("Publish Github Nuget") {
logger.stage()
def nugetName = "IO.Eventuate.Tram.${nextVersion}.nupkg"
withVault(vaultSecrets: [
[path: "jenkins/mediamanagement/services/github", secretValues: [[vaultKey: 'publish_token', envVar: 'GITHUB_TOKEN'], [vaultKey: 'user', envVar: 'GITHUB_USER']]],
[path: "jenkins/mediamanagement/services/nexus_nuget_settings", secretValues: [[vaultKey: 'file_release', envVar: 'nuget_config']]]
]) {
docker.image(sdkDotnetBaseImage).inside(imageEnvVar) {
sh """cat > ./NuGet.Config << EOL\n$nuget_config\nEOL"""
sh "dotnet nuget push ./IO.Eventuate.Tram/bin/Release/${nugetName} --source 'github'"
}
}
slackUtils.notifyBuild("The ${nugetName} nuget was released", slackChannel)
}
}
} catch (e) {
currentBuild.result = 'FAILURE'
throw e
} finally {
stage('Notify') {
slackUtils.notifyBuild(currentBuild.result, slackChannel)
}
stage('Clean Up') {
cleanWs()
}
}
}