forked from mRemoteNG/mRemoteNG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
44 lines (40 loc) · 1.68 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
node('windows') {
def jobDir = pwd()
def vsToolsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools"
def vsExtensionsDir = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow"
stage 'Checkout Branch'
def gitUrl = "https://github.com/mRemoteNG/mRemoteNG.git"
def branchName = GetBranchName()
echo "BranchName: ${branchName}"
git([url: gitUrl, branch: branchName])
stage 'Build mRemoteNG (Normal)'
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo \"${jobDir}\\mRemoteV1.sln\""
stage 'Build mRemoteNG (Portable)'
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && msbuild.exe /nologo /p:Configuration=\"Debug Portable\" \"${jobDir}\\mRemoteV1.sln\""
stage 'Run Unit Tests'
def nunitTestAdapterPath = "C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\VisualStudio\\14.0\\Extensions"
bat "\"${vsToolsDir}\\VsDevCmd.bat\" && VSTest.Console.exe /TestAdapterPath:${nunitTestAdapterPath} \"${jobDir}\\mRemoteNGTests\\bin\\debug\\mRemoteNGTests.dll\""
}
def GetBranchName() {
def jobDir = pwd()
echo "JobDir: ${jobDir}"
def patternToUse = GetPatternToMatchBranchNameFromDirectory()
echo "PatternToUse: ${patternToUse}"
java.util.regex.Matcher matcher = jobDir =~ patternToUse
echo "Ran the matcher"
matcher ? matcher[0][1] : null
}
def GetPatternToMatchBranchNameFromDirectory() {
def patternToUse = ""
def folderSeparator = ""
def branchNamePattern = "[a-zA-Z0-9\\-_]*"
def jenkinsJobInfoTag = "@*[0-9]*"
echo "isUnix: ${isUnix()}"
if (isUnix()) {
folderSeparator = "/"
} else {
folderSeparator = "\\\\"
}
patternToUse = "${folderSeparator}(${branchNamePattern})(${jenkinsJobInfoTag})\$"
patternToUse
}