-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
121 lines (94 loc) · 3.38 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
import groovy.json.JsonSlurperClassic
properties([[$class: 'GitLabConnectionProperty', gitLabConnection: 'NAS']])
env.REPO_NAME = "Janda.Dot.CLI"
env.FTP_BASE_URL = "ftp://nas/builds/dots-cli/"
def updateStatus(String status) {
updateGitlabCommitStatus(state: status);
}
def Object getGitVersion() {
jsonText = bat(returnStdout: true, script: '@gitversion')
println "${jsonText}"
return new JsonSlurperClassic().parseText(jsonText)
}
def String getPackageFtpLinkText(String link, String text) {
return hudson.console.ModelHyperlinkNote.encodeTo(env.FTP_BASE_URL + link, text);
}
def void getPackageLinks(Object gitVersion) {
branch = getPackageFtpLinkText("${gitVersion.BranchName}", gitVersion.BranchName)
version = getPackageFtpLinkText("${gitVersion.BranchName}/${gitVersion.InformationalVersion}", gitVersion.InformationalVersion)
println "Branch: ${branch}\nVersion: ${version}\n "
}
node("matt10") {
try {
def gitVersion
def packageName
def packageOutputPath
updateStatus('running')
stage('Init') {
milestone Integer.parseInt(env.BUILD_ID)
deleteDir()
}
stage('Checkout') {
milestone()
checkout scm
gitVersion = getGitVersion();
currentBuild.description = gitVersion.InformationalVersion
packageName = """${env.REPO_NAME}.${gitVersion.InformationalVersion}"""
packageOutputPath = """${env.DOT_CID_BUILD_PATH}\\${env.REPO_NAME}\\${env.BRANCH_NAME}\\${gitVersion.InformationalVersion}"""
}
stage('Pack') {
milestone()
def installScript = "${packageOutputPath}\\${packageName}.cmd"
bat """
set OUTPUT_DIR=${packageOutputPath}
call .pack
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
echo dotnet new -u ${env.REPO_NAME} > ${installScript}
echo dotnet new -i ${packageOutputPath}\\${packageName}.nupkg >> ${installScript}
echo pause >> ${installScript}
"""
}
/*
stage('Install') {
milestone()
// remove all templateengine folder in case previous build fails
bat """
rd %USERPROFILE%\\.templateengine /s/q
dotnet new -l && if %ERRORLEVEL% NEQ 0 exit %ERRORLEVEL%
dotnet new -i ${packageOutputPath}\\${packageName}.nupkg && if %ERRORLEVEL% NEQ 0 exit %ERRORLEVEL%
"""
}
stage('Deploy') {
milestone()
// install global .dots
bat """
.install
"""
}*/
stage('Tests') {
milestone()
// install global .dots
//bat """
// for /f %%f in ('dir /b tests\\*.cmd') do echo.&echo *** RUNNING TEST: %%f&call tests\\%%f
//"""
}
stage('Uninstall') {
milestone()
bat """
call .uninstall
"""
}
stage('Cleanup') {
milestone()
deleteDir()
}
stage ('Package') {
getPackageLinks(gitVersion)
}
updateStatus('success')
}
catch (e) {
updateStatus('failed')
throw e
}
}