Skip to content

Commit

Permalink
Deployment support with versioning and signatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangha182 committed Nov 29, 2022
1 parent 818280e commit a666238
Show file tree
Hide file tree
Showing 4 changed files with 902 additions and 26 deletions.
212 changes: 186 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,76 @@
// Global constants

// Name of the project, used in the subject of the email with the build results
PROJECT_NAME = 'USD'
PROJECT_NAME = 'usd'

// Email of the project maintaner, who will receive all updates regarless of the branch.
PROJECT_MAINTAINER = '[email protected]'
PROJECT_MAINTAINER = '[email protected]'

ARTIFACTORY_URL = 'https://art-toucan.autodesk.com/artifactory'
ARTIFACTORY_FOLDER = 'team-gfx-generic/usd'
ARTIFACTORY_URL = 'https://art-toucan.autodesk.com/artifactory'
ARTIFACTORY_FOLDER = 'team-gfx-generic/usd'

// See the Jenkins configuration for the available credentials
// https://master-1.jenkins.autodesk.com/job/autodesk-forks/job/USD/credentials/
DEPLOY_CREDENTIALS = [$class: 'StringBinding',
credentialsId: 'art-bobcat-ogsmod-api-key',
variable: 'ARTIFACTORY_APIKEY']

COMMONSHELL = new ors.utils.CommonShell(steps, env)

BUILD_DEBUG = false
BUILD_LINUX = true


///////////////////////////////////////////////////
// Main program

def jobParams = [
[$class: 'BooleanParameterDefinition',
defaultValue: false,
description: 'Check it to enable Debug build',
name: 'BUILD_DEBUG'
],
[$class: 'BooleanParameterDefinition',
defaultValue: true,
description: 'Check it to enable Linux build',
name: 'BUILD_LINUX'
]
]
properties([
[$class: 'ParametersDefinitionProperty', parameterDefinitions: jobParams]]
)
if (env.getProperty("BUILD_DEBUG")) {
BUILD_DEBUG = env.BUILD_DEBUG.toBoolean()
}
if (env.getProperty("BUILD_LINUX")) {
BUILD_LINUX = env.BUILD_LINUX.toBoolean()
}

// Create a map of node closures that parallelizes over to build.
def builds = [:]
builds['windows_x64'] = { windowsNode('x64') }
builds['mac_x64'] = { macNode('x64') }
builds['linux_x64'] = { linuxNode('x64') }
builds['mac_x64'] = { macNode('x64') }
if (BUILD_LINUX) {
builds['linux_x64'] = { linuxNode('x64') }
}

def windowsNode(platform) {
node('OGS_Win_001') {
try {
withEnv(["WORKSPACE_ON_NODE=${env.WORKSPACE}"]) {
checkoutStage('windows')

def buildInfo = getBuildInfo('windows', platform, 'release')
def buildInfo = getBuildInfo('windows', platform, 'RelWithDebInfo')
buildStage(buildInfo, this.&windowsBuild)
testStage(buildInfo, this.&windowsTest)
deployStage(buildInfo, this.&genericDeploy)

// buildInfo = getBuildInfo('windows', platform, 'debug')
// buildStage(buildInfo, this.&windowsBuild)
// testStage(buildInfo, this.&windowsTest)
if (BUILD_DEBUG) {
buildInfo = getBuildInfo('windows', platform, 'Debug')
buildStage(buildInfo, this.&windowsBuild)
testStage(buildInfo, this.&windowsTest)
deployStage(buildInfo, this.&genericDeploy)
}
}
}
finally {
Expand All @@ -52,13 +91,17 @@ def macNode(platform) {
withEnv(["WORKSPACE_ON_NODE=${env.WORKSPACE}"]) {
checkoutStage('mac')

def buildInfo = getBuildInfo('mac', platform, 'release')
def buildInfo = getBuildInfo('mac', platform, 'RelWithDebInfo')
buildStage(buildInfo, this.&macBuild)
testStage(buildInfo, this.&macTest)
deployStage(buildInfo, this.&genericDeploy)

// buildInfo = getBuildInfo('mac', platform, 'debug')
// buildStage(buildInfo, this.&macBuild)
// testStage(buildInfo, this.&macTest)
if (BUILD_DEBUG) {
buildInfo = getBuildInfo('mac', platform, 'Debug')
buildStage(buildInfo, this.&macBuild)
testStage(buildInfo, this.&macTest)
deployStage(buildInfo, this.&genericDeploy)
}
}
}
finally {
Expand All @@ -80,14 +123,18 @@ def linuxNode(platform) {
def buildImage = "autodesk-docker.art-toucan.autodesk.com/gfx/gfx-vulkan-builder"
docker.image("${buildImage}").pull()
docker.image("${buildImage}").inside("-u root --gpus all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics -v /tmp:/tmp") {
def buildInfo = getBuildInfo('linux', platform, 'release')
def buildInfo = getBuildInfo('linux', platform, 'RelWithDebInfo')
buildStage(buildInfo, this.&linuxBuild)
//Comment out test steps as the docker inside of Linux VM can't initilize QT plugin properly
//testStage(buildInfo, this.&linuxTest)

// buildInfo = getBuildInfo('linux', platform, 'debug')
// buildStage(buildInfo, this.&linuxBuild)
// testStage(buildInfo, this.&linuxTest)
deployStage(buildInfo, this.&genericDeploy)

if (BUILD_DEBUG) {
buildInfo = getBuildInfo('linux', platform, 'Debug')
buildStage(buildInfo, this.&linuxBuild)
testStage(buildInfo, this.&linuxTest)
deployStage(buildInfo, this.&genericDeploy)
}
}
}
}
Expand All @@ -106,8 +153,10 @@ finally {
// Generate a list of all build configurations.
def buildConfigs = []
for (build in builds) {
buildConfigs << "${build.key}_release"
// buildConfigs << "${build.key}_debug"
buildConfigs << "${build.key}_RelWithDebInfo"
if (BUILD_DEBUG) {
buildConfigs << "${build.key}_Debug"
}
}

// Skip to post for empty buildconfig
Expand All @@ -126,10 +175,9 @@ finally {
// Helper Functions

def checkoutGit() {
commonShell = new ors.utils.CommonShell(steps, env)
String branch = scm.branches[0].toString()
withGit {
commonShell.shell """
COMMONSHELL.shell """
git clone -b ${branch} --recurse-submodules https://git.autodesk.com/autodesk-forks/usd .
git lfs pull
"""
Expand All @@ -147,11 +195,21 @@ def getBuildInfo(os, platform, config) {
USDarts = WORKSPACE_ON_NODE + sep + '..' + sep + 'USDarts'
}

if (config == 'Debug') {
buildVariant = 'debug'
}
else if (config == 'RelWithDebInfo') {
buildVariant = 'relwithdebuginfo'
}
else {
buildVariant = 'release'
}

// Store for future references
def buildInfo = [:]
buildInfo.Platform = "${os}_${platform}_${config}"
buildInfo.BuildVariant = config == 'debug' ? 'debug' : 'relwithdebuginfo'
buildInfo.CMakeConfig = config == 'debug' ? 'Debug' : 'RelWithDebInfo'
buildInfo.BuildVariant = buildVariant
buildInfo.CMakeConfig = config
buildInfo.USDinst = USDarts + sep + buildInfo.BuildVariant + sep + 'USDinst'
buildInfo.USDgen_src = USDarts + sep + buildInfo.BuildVariant + sep + 'USDgen' + sep + 'src'
buildInfo.USDgen_build = USDarts + sep + buildInfo.BuildVariant + sep + 'USDgen' + sep + 'build'
Expand Down Expand Up @@ -200,6 +258,17 @@ def isLastTestsFailed(buildInfo) {
return false
}

def isDevBranch(){
return env.BRANCH_NAME == "adsk/dev"
}

def isReleaseBranch(){
def match = env.BRANCH_NAME =~/(?i)^adsk\/release\/.*/
def result = match ? true : false
match = null
return result
}


///////////////////////////////////////////////////
// Checkout functions
Expand Down Expand Up @@ -333,7 +402,6 @@ def macTest(buildInfo) {
"""
}


def linuxTest(buildInfo) {
sh """
apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libxrender-dev libxkbcommon-dev libxkbcommon-x11-dev;
Expand All @@ -346,6 +414,98 @@ def linuxTest(buildInfo) {
}


///////////////////////////////////////////////////
// Deploy functions

// Generic deploy stage. Takes the platform-specific deploy steps as a parameter.
def deployStage(buildInfo, runDeploy) {
if (!(isDevBranch() || isReleaseBranch())) {
echo "*** Warnings: Deployment of artifacts package is skipped because this is not a release branch or dev branch. ***"
return
}

if ("${buildInfo.Platform}".contains('windows')) {
stage("Versioning ${buildInfo.Platform}") {
try {
COMMONSHELL.shell """\
python adsk-build-scripts/deploy.py --add_version --source ${buildInfo.USDinst}
"""
postStatus('SUCCESS', "${buildInfo.Platform}_versioning")
}
catch (err) {
echo "*** VERSIONING FAILURE on ${buildInfo.Platform}.\nInternal error message: ${err.message} ***"
postStatus('FAILURE', "${buildInfo.Platform}_versioning")
throw err
}
finally {
}
}

stage("Garasign ${buildInfo.Platform}") {
try {
COMMONSHELL.shell """\
python adsk-build-scripts/deploy.py --add_sign --source ${buildInfo.USDinst}
"""
sign_args = [
'include_list': "toSign.txt",
]

withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'garasign_appid_secret',usernameVariable: 'client_app_id',passwordVariable: 'client_app_secret']])
{
sign_args['client_app_id'] = client_app_id
sign_args['client_app_secret'] = client_app_secret
}
sign_args['verify_before_sign'] = true

garasign = new ors.security.CommonGarasign(steps, env, Artifactory, scm)
garasign.run_garasign(sign_args)
postStatus('SUCCESS', "${buildInfo.Platform}_garasign")
}
catch (err) {
echo "*** GARASIGN FAILURE on ${buildInfo.Platform}.\nInternal error message: ${err.message} ***"
postStatus('FAILURE', "${buildInfo.Platform}_garasign")
throw err
}
finally {
}
}
}

stage("Deploy ${buildInfo.Platform}") {
try {
runDeploy(buildInfo)
postStatus('SUCCESS', "${buildInfo.Platform}_deployment")
}
catch (err) {
echo "*** DEPLOY FAILURE on ${buildInfo.Platform}.\nInternal error message: ${err.message} ***"
postStatus('FAILURE', "${buildInfo.Platform}_deployment")
throw err
}
finally {
}
}
}

def genericDeploy(buildInfo) {
def pyExe = isUnix() ? "python3" : 'python'
def artifactory_env_path = env.BRANCH_NAME
def remotePath = "${ARTIFACTORY_FOLDER}/${artifactory_env_path}"
def targetDir = 'archive'
def git_url = readCommandOutput 'git remote get-url origin'
def commit = readCommandOutput 'git rev-parse HEAD'

withCredentials([DEPLOY_CREDENTIALS]) {
COMMONSHELL.shell """\
${pyExe} adsk-build-scripts/deploy.py --deploy --packagename ${PROJECT_NAME} \
--branch ${env.BRANCH_NAME} --git_url ${git_url} --git_commit ${commit} \
--platform ${buildInfo.Platform} --source ${buildInfo.USDinst} --path ${targetDir} \
--server ${ARTIFACTORY_URL} --remotepath ${remotePath} \
--apikey ${env.ARTIFACTORY_APIKEY}
"""
}
}


///////////////////////////////////////////////////
// Build status reporting

Expand Down
Binary file added adsk-build-scripts/ResourceHacker.exe
Binary file not shown.
Loading

0 comments on commit a666238

Please sign in to comment.