forked from afonsoft/CxViewerVSIX
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Jenkinsfile
85 lines (80 loc) · 3.59 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
#!/groovy
@Library('cx-jenkins-pipeline-kit')
def ipAddress
def vmName = "Plugin-VisualStudio-" + UUID.randomUUID().toString()
def msbuildLocationVS2019 = "\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe\""
def msbuildLocationVS2022 = "\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\MSBuild\\Current\\Bin\\MSBuild.exe\""
pipeline {
parameters {
string(name: "decommissionPeriod", defaultValue: "3 hour", description: "Decommission period")
choice(name: "templateName", choices: ["VisualStudio2019-Template","VisualStudio2022-Template"], description: "Template name, if not specified then \"VisualStudio2019-Template\" template will be chosen")
booleanParam(name: 'doNotDeleteVM', defaultValue: false, description: 'If selected, VM will not be deleted after process finished')
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'branch', type: 'PT_BRANCH'
}
agent { node { label 'install01' } }
stages {
stage('Create VM') {
steps {
script {
kit.Create_Vm_Terraform(vmName, templateName, "18000", "8", "VMWARE", decommissionPeriod, "Auto", "Plugins-Developers")
ipAddress = kit.getIpAddress(vmName, "VMWARE")
kit.Create_Jenkins_Slave_On_Master(vmName)
kit.Start_Jenkins_Slave_On_Windows_Pstools(ipAddress, vmName)
}
}
}
stage('Build and Pack') {
agent { node { label vmName } }
steps {
script {
if(templateName == "VisualStudio2019-Template")
{
bat "${msbuildLocationVS2019} ${WORKSPACE}\\ci.msbuild /t:CI /p:VisualStudioVersion=\"16.0\" /p:DeployExtension=false"
}
else {
bat "${msbuildLocationVS2022} ${WORKSPACE}\\ci.msbuild2022 /t:CI /p:VisualStudioVersion=\"17.0\" /p:DeployExtension=false"
}
}
}
}
stage('Upload To Artifactory') {
agent { node { label vmName } }
steps {
script {
if(templateName == "VisualStudio2019-Template")
{
fileOperations([folderRenameOperation(source: "${WORKSPACE}\\Artifacts\\CxViewerVSIX-2019.vsix", destination: "${WORKSPACE}\\Artifacts\\CxViewerVSIX-9.00.19.vsix")])
kit.Upload_To_Artifactory("${WORKSPACE}\\Artifacts\\CxViewerVSIX-9.00.19.vsix", "plugins-release-local/com/checkmarx/visual-studio/")
}
else
{
fileOperations([folderRenameOperation(source: "${WORKSPACE}\\Artifacts\\CxViewerVSIX-2022.vsix", destination: "${WORKSPACE}\\Artifacts\\CxViewerVSIX-9.00.19.vsix")])
kit.Upload_To_Artifactory("${WORKSPACE}\\Artifacts\\CxViewerVSIX-9.00.19.vsix", "plugins-release-local/com/checkmarx/visual-studio/")
}
}
}
}
}
post {
always {
script {
//logstashSend failBuild: false, maxLines: 1000 - commented code due to job failed because of logstashSend plugin not found
if (ipAddress != null) {
try {
if (doNotDeleteVM == 'true') {
kit.Info_Msg("Not deleting VM since user chose to keep it")
} else {
deleteVm("VMWARE", ipAddress, vmName)
}
} catch (Exception e) {
kit.Warning_Msg("Failed to delete vm. Exception:\n" + e.toString())
currentBuild.result = 'UNSTABLE'
}
}
}
}
cleanup {
cleanWs()
}
}
}