Skip to content

Plug 2052 - Modify Plugin-VisualStudio-9.0 pipeline to generate build dynamically #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d7806ad
upgraded version
cx-rah-pid Feb 3, 2025
ead023c
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
c1798f8
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
80586db
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
93fed0f
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
65ab585
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
7902316
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
d3fe5bf
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
66ee14b
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
b314f52
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
fba507e
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
253bf8b
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
4864175
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
8f5dca8
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
8bac450
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
07e5566
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
55a18ed
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
b4640bf
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
2912de3
Update Jenkinsfile
cx-rah-pid Feb 3, 2025
aeca364
Update source.extension.vsixmanifest
cx-rah-pid Feb 3, 2025
2ded4a3
Update source.extension.vsixmanifest
cx-rah-pid Feb 3, 2025
ce75783
Update Jenkinsfile
cx-rah-pid Feb 5, 2025
61b1283
Update Jenkinsfile
cx-rah-pid Feb 5, 2025
4bb2318
Update Jenkinsfile
cx-rah-pid Feb 5, 2025
03f2569
Update Jenkinsfile
cx-rah-pid Feb 5, 2025
ff12c4d
Update Jenkinsfile
cx-rah-pid Feb 5, 2025
49af29b
Update source.extension.vsixmanifest
cx-rah-pid Feb 5, 2025
ffe7398
Update source.extension.vsixmanifest
cx-rah-pid Feb 5, 2025
81ab366
Update source.extension.vsixmanifest
cx-rah-pid Feb 6, 2025
9153b5e
Update source.extension.vsixmanifest
cx-rah-pid Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 57 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
#!/groovy
@Library('cx-jenkins-pipeline-kit')
import groovy.xml.DOMBuilder
import groovy.xml.XmlUtil
import javax.xml.parsers.DocumentBuilderFactory
import org.w3c.dom.Document

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 msbuildLocationVS2019 = "\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\MSBuild\\Current\\Bin\\MSBuild.exe\""
def msbuildLocationVS2022 = "\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\MSBuild\\Current\\Bin\\MSBuild.exe\""
def versionOfVS2022
def versionOfVS2019
def decommissionPeriod = "3 hour"

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('Extract Version') {
steps {
script {
if(templateName == "VisualStudio2019-Template")
{
def vs2019ManifestPath = 'CxViewerVSIX/source.extension.vsixmanifest'
// Extract versions using a helper function
versionOfVS2019 = extractVersionUsingDOMBuilder(vs2019ManifestPath)
echo "VS2019 version: ${versionOfVS2019}"
}
else
{
def vs2022ManifestPath = 'CxViewer2022/source.extension.vsixmanifest'
// Extract versions using a helper function
versionOfVS2022 = extractVersionUsingDOMBuilder(vs2022ManifestPath)
echo "VS2022 version: ${versionOfVS2022}"
}
}
}
}
stage('Create VM') {
steps {
script {
Expand All @@ -25,7 +51,7 @@ pipeline {
}
}
}

stage('Build and Pack') {
agent { node { label vmName } }
steps {
Expand All @@ -41,19 +67,17 @@ pipeline {
}
}

stage('Upload To Artifactory') {
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/")
kit.Upload_To_Artifactory("${WORKSPACE}\\Artifacts\\CxViewerVSIX-2019.vsix", "plugins-release-local/com/checkmarx/visual-studio/${versionOfVS2019}/")
}
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/")
kit.Upload_To_Artifactory("${WORKSPACE}\\Artifacts\\CxViewerVSIX-2022.vsix", "plugins-release-local/com/checkmarx/visual-studio/${versionOfVS2022}/")
}
}
}
Expand Down Expand Up @@ -83,3 +107,28 @@ pipeline {
}
}
}
def extractVersionUsingDOMBuilder(manifestPath) {
def manifestContent = readFile(manifestPath)
manifestContent = manifestContent.replaceFirst(/^\xEF\xBB\xBF/, '').trim()

def version = ''
try {
// Create DocumentBuilderFactory and parse the XML content
def factory = DocumentBuilderFactory.newInstance()
def builder = factory.newDocumentBuilder()
def inputStream = new ByteArrayInputStream(manifestContent.getBytes("UTF-8"))

// Parse the input stream into a Document
Document document = builder.parse(inputStream)

// Use DOM to extract the Version attribute
def node = document.getElementsByTagName("Identity").item(0)
version = node?.getAttribute("Version")
if (!version) {
error "Version attribute not found in ${manifestPath}"
}
return version
} catch (Exception e) {
error "Failed to parse XML using DOMBuilder for ${manifestPath}: ${e.message}"
}
}