2017-01-18 14:33:36 +01:00
|
|
|
#!groovy
|
|
|
|
|
2017-12-07 15:39:32 +01:00
|
|
|
/* Copyright (c) Citrix Systems Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
* that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
* following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
* materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
2017-01-18 14:33:36 +01:00
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2017-01-25 12:42:22 +01:00
|
|
|
/* Note: the env variables are either Jenkins built-in variables
|
|
|
|
or own variables configured at Manage Jenkins > Configure System */
|
|
|
|
|
2017-01-18 14:33:36 +01:00
|
|
|
properties([
|
|
|
|
[
|
|
|
|
$class : 'BuildDiscarderProperty',
|
|
|
|
strategy: [$class: 'LogRotator', numToKeepStr: '10', artifactNumToKeepStr: '10']
|
2020-01-13 13:37:35 +01:00
|
|
|
]
|
2017-01-18 14:33:36 +01:00
|
|
|
])
|
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
node('xencenter') {
|
2017-01-18 14:33:36 +01:00
|
|
|
try {
|
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
// The job name should be xencenter-<branding>
|
|
|
|
def jobName = "${env.JOB_NAME}".tokenize('/')[0]
|
|
|
|
def XC_BRANDING = jobName.split('-')[1]
|
|
|
|
println "Branding for ${XC_BRANDING}"
|
|
|
|
|
|
|
|
def GIT_COMMIT_XENADMIN = ''
|
|
|
|
def GIT_BRANCH_XENADMIN = ''
|
|
|
|
def GLOBAL_BUILD_NUMBER = ''
|
|
|
|
|
|
|
|
stage('Bump global build number') {
|
|
|
|
GLOBAL_BUILD_NUMBER = build('xencenter-global-build-number').number
|
|
|
|
currentBuild.displayName = "${GLOBAL_BUILD_NUMBER}"
|
2017-01-18 14:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Clean workspace') {
|
|
|
|
deleteDir()
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Checkout sources') {
|
|
|
|
checkout([
|
|
|
|
$class : 'GitSCM',
|
2020-01-13 13:37:35 +01:00
|
|
|
branches : scm.branches,
|
2017-01-18 14:33:36 +01:00
|
|
|
extensions : [
|
|
|
|
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'xenadmin.git'],
|
|
|
|
[$class: 'LocalBranch', localBranch: '**'],
|
|
|
|
[$class: 'CleanCheckout'],
|
|
|
|
[$class: 'CloneOption', noTags: false, reference: '', shallow: true]
|
|
|
|
],
|
|
|
|
userRemoteConfigs: scm.userRemoteConfigs
|
|
|
|
])
|
|
|
|
|
|
|
|
GIT_COMMIT_XENADMIN = bat(
|
|
|
|
returnStdout: true,
|
|
|
|
script: """
|
2017-12-07 15:39:32 +01:00
|
|
|
@echo off
|
2017-01-18 14:33:36 +01:00
|
|
|
cd ${env.WORKSPACE}\\xenadmin.git
|
|
|
|
git rev-parse HEAD
|
|
|
|
"""
|
|
|
|
).trim()
|
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
GIT_BRANCH_XENADMIN = bat(
|
|
|
|
returnStdout: true,
|
|
|
|
script: """
|
|
|
|
@echo off
|
|
|
|
cd ${env.WORKSPACE}\\xenadmin.git
|
|
|
|
git rev-parse --abbrev-ref HEAD
|
|
|
|
"""
|
|
|
|
).trim()
|
|
|
|
|
|
|
|
GString brandingRemote = "${env.CODE_ENDPOINT}/xs/branding.git"
|
2017-01-18 14:33:36 +01:00
|
|
|
|
2017-04-28 13:50:16 +02:00
|
|
|
def branchExistsOnBranding = bat(
|
|
|
|
returnStatus: true,
|
2020-01-13 13:37:35 +01:00
|
|
|
script: """git ls-remote --heads ${brandingRemote} | grep ${GIT_BRANCH_XENADMIN}"""
|
2017-04-28 13:50:16 +02:00
|
|
|
)
|
2020-01-13 13:37:35 +01:00
|
|
|
String branchToCloneOnBranding = (branchExistsOnBranding == 0) ? "${GIT_BRANCH_XENADMIN}" : 'master'
|
2017-01-18 14:33:36 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
bat """git clone -b ${branchToCloneOnBranding} ${brandingRemote} ${env.WORKSPACE}\\branding.git"""
|
2017-12-07 15:39:32 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
if ("${XC_BRANDING}" != 'citrix') {
|
2017-01-18 14:33:36 +01:00
|
|
|
|
|
|
|
println "Overwriting Branding folder"
|
2020-01-13 13:37:35 +01:00
|
|
|
GString xenadminBrandingRemote = "${env.CODE_ENDPOINT}/xsc/xenadmin-branding.git"
|
2017-01-18 14:33:36 +01:00
|
|
|
|
|
|
|
def branchExistsOnBrand = bat(
|
|
|
|
returnStatus: true,
|
2020-01-13 13:37:35 +01:00
|
|
|
script: """git ls-remote --heads ${xenadminBrandingRemote} | grep ${GIT_BRANCH_XENADMIN}"""
|
2017-01-18 14:33:36 +01:00
|
|
|
)
|
2020-01-13 13:37:35 +01:00
|
|
|
String branchToClone = (branchExistsOnBrand == 0) ? "${GIT_BRANCH_XENADMIN}" : 'master'
|
2017-01-18 14:33:36 +01:00
|
|
|
|
|
|
|
bat """
|
2020-01-13 13:37:35 +01:00
|
|
|
git clone -b ${branchToClone} ${xenadminBrandingRemote} ${env.WORKSPACE}\\xenadmin-branding.git
|
2017-01-18 14:33:36 +01:00
|
|
|
rmdir /s /q "${env.WORKSPACE}\\xenadmin.git\\Branding"
|
2020-01-13 13:37:35 +01:00
|
|
|
xcopy /e /y "${env.WORKSPACE}\\xenadmin-branding.git\\${XC_BRANDING}\\*" "${env.WORKSPACE}\\xenadmin.git\\"
|
2017-01-18 14:33:36 +01:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Download dependencies') {
|
2017-02-17 18:01:10 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
def remoteDotnet = readFile("${env.WORKSPACE}\\xenadmin.git\\packages\\DOTNET_BUILD_LOCATION").trim()
|
2020-02-22 16:17:19 +01:00
|
|
|
def downloadSpec = readFile("${env.WORKSPACE}\\xenadmin.git\\scripts\\deps-map.json").trim().replaceAll("@REMOTE_DOTNET@", remoteDotnet)
|
2017-01-18 14:33:36 +01:00
|
|
|
|
|
|
|
def server = Artifactory.server('repo')
|
|
|
|
server.download(downloadSpec)
|
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
if ("${XC_BRANDING}" == 'citrix') {
|
2017-01-18 14:33:36 +01:00
|
|
|
println "Downloading hotfixes."
|
|
|
|
|
2020-02-22 16:17:19 +01:00
|
|
|
def hotFixSpec = readFile("${env.WORKSPACE}\\xenadmin.git\\scripts\\hotfix-map.json").trim()
|
2017-01-18 14:33:36 +01:00
|
|
|
server.download(hotFixSpec)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:59:29 +01:00
|
|
|
stage('Run checks') {
|
2020-03-05 01:23:44 +01:00
|
|
|
dir("${env.WORKSPACE}\\xenadmin.git") {
|
|
|
|
powershell ".\\scripts\\check_copyright.ps1"
|
|
|
|
powershell ".\\scripts\\check_i18n.ps1"
|
|
|
|
}
|
2018-03-09 17:59:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build') {
|
2020-01-13 13:37:35 +01:00
|
|
|
def sbe = "${GIT_BRANCH_XENADMIN}".startsWith('release').toString().toLowerCase()
|
|
|
|
|
2018-03-09 17:59:29 +01:00
|
|
|
bat """
|
2020-01-13 13:37:35 +01:00
|
|
|
cd ${env.WORKSPACE}
|
2020-02-22 16:17:19 +01:00
|
|
|
sh xenadmin.git/scripts/xenadmin-build.sh ${GLOBAL_BUILD_NUMBER} ${env.SIGNING_NODE_NAME} ${sbe} ${env.SELFSIGN_THUMBPRINT_SHA1} ${env.SELFSIGN_THUMBPRINT_SHA256} ${env.TIMESTAMP_SERVER_URL}
|
2020-01-13 13:37:35 +01:00
|
|
|
"""
|
2018-03-09 17:59:29 +01:00
|
|
|
}
|
|
|
|
|
2017-01-18 14:33:36 +01:00
|
|
|
stage('Create manifest') {
|
2019-12-26 18:23:32 +01:00
|
|
|
GString manifestFile = "${env.WORKSPACE}\\xenadmin.git\\_output\\xenadmin-manifest.txt"
|
2017-01-18 14:33:36 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
def brandingTip = bat(
|
2017-04-28 14:26:06 +02:00
|
|
|
returnStdout: true,
|
|
|
|
script: """
|
2017-12-07 15:39:32 +01:00
|
|
|
@echo off
|
2017-01-18 14:33:36 +01:00
|
|
|
cd ${env.WORKSPACE}\\branding.git
|
|
|
|
git rev-parse HEAD
|
|
|
|
"""
|
2017-04-28 14:26:06 +02:00
|
|
|
).trim()
|
2017-01-18 14:33:36 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
powershell """
|
|
|
|
"xenadmin xenadmin.git ${GIT_COMMIT_XENADMIN}" | Out-File -FilePath ${manifestFile}
|
|
|
|
"branding branding.git ${brandingTip}" | Out-File -FilePath ${manifestFile} -Append
|
|
|
|
"""
|
2017-01-18 14:33:36 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
if ("${XC_BRANDING}" != 'citrix') {
|
|
|
|
def xenadminBrandingTip = bat(
|
2017-01-18 14:33:36 +01:00
|
|
|
returnStdout: true,
|
|
|
|
script: """
|
2017-12-07 15:39:32 +01:00
|
|
|
@echo off
|
2017-01-18 14:33:36 +01:00
|
|
|
cd ${env.WORKSPACE}\\xenadmin-branding.git
|
|
|
|
git rev-parse HEAD
|
|
|
|
"""
|
|
|
|
).trim()
|
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
powershell """
|
|
|
|
"xenadmin-branding xenadmin-branding.git" ${xenadminBrandingTip} | Out-File -FilePath ${manifestFile} -Append
|
|
|
|
"""
|
2017-01-18 14:33:36 +01:00
|
|
|
}
|
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
def dotNetManifest = readFile("${env.WORKSPACE}\\xenadmin.git\\packages\\dotnet-packages-manifest.txt").trim()
|
2017-01-18 14:33:36 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
powershell """
|
|
|
|
"xencenter-ovf xencenter-ovf.git 21d3d7a7041f15abfa73f916e5fd596fd7e610c4" | Out-File -FilePath ${manifestFile} -Append
|
|
|
|
"chroot-lenny chroots.hg 1a75fa5848e8" | Out-File -FilePath ${manifestFile} -Append
|
|
|
|
"${dotNetManifest}" | Out-File -FilePath ${manifestFile} -Append
|
|
|
|
"""
|
2017-01-18 14:33:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Run tests') {
|
2020-01-13 13:37:35 +01:00
|
|
|
timeout(time: 60, unit: 'MINUTES') {
|
|
|
|
bat """
|
2019-07-12 15:59:01 +02:00
|
|
|
taskkill /f /fi "imagename eq nunit*"
|
2017-12-07 15:39:32 +01:00
|
|
|
|
2019-07-12 15:59:01 +02:00
|
|
|
nunit3-console /labels=all /process=separate /timeout=40000 /where "cat==Unit" ^
|
2019-12-26 18:23:32 +01:00
|
|
|
/out="${env.WORKSPACE}\\xenadmin.git\\_output\\XenAdminTests.out" ^
|
|
|
|
/result="${env.WORKSPACE}\\xenadmin.git\\_output\\XenAdminTests.xml" ^
|
2019-07-12 15:59:01 +02:00
|
|
|
"${env.WORKSPACE}\\xenadmin.git\\XenAdminTests\\bin\\Release\\XenAdminTests.dll" ^
|
2019-12-26 18:23:32 +01:00
|
|
|
> ${env.WORKSPACE}\\xenadmin.git\\_output\\nunit3-console.out
|
2017-12-07 15:39:32 +01:00
|
|
|
|
2019-12-26 18:23:32 +01:00
|
|
|
type ${env.WORKSPACE}\\xenadmin.git\\_output\\nunit3-console.out
|
2019-07-12 15:59:01 +02:00
|
|
|
"""
|
2017-01-18 14:33:36 +01:00
|
|
|
|
2020-01-13 13:37:35 +01:00
|
|
|
def text = readFile("${env.WORKSPACE}\\xenadmin.git\\_output\\nunit3-console.out")
|
|
|
|
assert text.contains('Failed: 0')
|
2017-01-18 14:33:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Upload') {
|
2020-01-13 13:37:35 +01:00
|
|
|
dir("${env.WORKSPACE}\\xenadmin.git\\_output") {
|
|
|
|
|
|
|
|
def server = Artifactory.server('repo')
|
|
|
|
def buildInfo = Artifactory.newBuildInfo()
|
|
|
|
buildInfo.env.filter.addInclude("*")
|
|
|
|
buildInfo.env.collect()
|
|
|
|
|
|
|
|
GString artifactMeta = "build.name=${env.JOB_NAME};build.number=${GLOBAL_BUILD_NUMBER};vcs.url=${env.CHANGE_URL};vcs.branch=${GIT_BRANCH_XENADMIN};vcs.revision=${GIT_COMMIT_XENADMIN}"
|
|
|
|
|
|
|
|
// IMPORTANT: do not forget the slash at the end of the target path!
|
|
|
|
GString targetPath = "xc-local-build/xencenter/${GIT_BRANCH_XENADMIN}/${XC_BRANDING}/${GLOBAL_BUILD_NUMBER}/"
|
|
|
|
GString uploadSpec = """ {
|
|
|
|
"files": [
|
|
|
|
{ "pattern": "*", "flat": "false", "target": "${targetPath}", "props": "${artifactMeta}" }
|
|
|
|
]}
|
|
|
|
"""
|
|
|
|
|
|
|
|
def buildInfo_upload = server.upload(uploadSpec)
|
|
|
|
buildInfo.append buildInfo_upload
|
|
|
|
server.publishBuildInfo buildInfo
|
2017-01-18 14:33:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
currentBuild.result = 'SUCCESS'
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
currentBuild.result = 'FAILURE'
|
|
|
|
throw ex as java.lang.Throwable
|
|
|
|
} finally {
|
|
|
|
step([
|
|
|
|
$class : 'Mailer',
|
|
|
|
notifyEveryUnstableBuild: true,
|
|
|
|
recipients : "${env.XENCENTER_DEVELOPERS}",
|
|
|
|
sendToIndividuals : true])
|
|
|
|
}
|
|
|
|
}
|