mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Add artifactory publish step
This change simplifies the build process by only targetting ubuntu20.04-amd64 and adds logic to push tagged builds to artifactory. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
46de426cc4
commit
de172674b1
114
Jenkinsfile
vendored
114
Jenkinsfile
vendored
@ -20,9 +20,12 @@ podTemplate (cloud:'sw-gpu-cloudnative',
|
||||
containerTemplate(name: 'golang', image: 'golang:1.14.2', ttyEnabled: true)
|
||||
]) {
|
||||
node(POD_LABEL) {
|
||||
def scmInfo
|
||||
|
||||
stage('checkout') {
|
||||
checkout scm
|
||||
scmInfo = checkout(scm)
|
||||
}
|
||||
|
||||
stage('dependencies') {
|
||||
container('golang') {
|
||||
sh 'GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell'
|
||||
@ -30,7 +33,7 @@ podTemplate (cloud:'sw-gpu-cloudnative',
|
||||
sh 'GO111MODULE=off go get -u golang.org/x/lint/golint'
|
||||
}
|
||||
container('docker') {
|
||||
sh 'apk add --no-cache make bash'
|
||||
sh 'apk add --no-cache make bash git'
|
||||
}
|
||||
}
|
||||
stage('check') {
|
||||
@ -43,15 +46,54 @@ podTemplate (cloud:'sw-gpu-cloudnative',
|
||||
getGolangStages(["test"])
|
||||
)
|
||||
}
|
||||
stage('build-one') {
|
||||
parallel (
|
||||
getSingleBuildForArchitectures(["amd64", "ppc64le", "arm64"])
|
||||
)
|
||||
|
||||
def versionInfo
|
||||
stage('version') {
|
||||
container('docker') {
|
||||
versionInfo = getVersionInfo(scmInfo)
|
||||
println "versionInfo=${versionInfo}"
|
||||
}
|
||||
}
|
||||
stage('build-all') {
|
||||
parallel (
|
||||
getAllBuildForArchitectures(["amd64", "ppc64le", "arm64", "x86_64", "aarch64"])
|
||||
)
|
||||
|
||||
def dist = 'ubuntu20.04'
|
||||
def arch = 'amd64'
|
||||
def stageLabel = "${dist}-${arch}"
|
||||
|
||||
stage('build-one') {
|
||||
container('docker') {
|
||||
stage (stageLabel) {
|
||||
sh "make ${dist}-${arch}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('release') {
|
||||
container('docker') {
|
||||
stage (stageLabel) {
|
||||
|
||||
def component = 'main'
|
||||
def repository = 'sw-gpu-cloudnative-debian-local/pool/main/'
|
||||
|
||||
def uploadSpec = """{
|
||||
"files":
|
||||
[ {
|
||||
"pattern": "./dist/${dist}/${arch}/*.deb",
|
||||
"target": "${repository}",
|
||||
"props": "deb.distribution=${dist};deb.component=${component};deb.architecture=${arch}"
|
||||
}
|
||||
]
|
||||
}"""
|
||||
|
||||
sh "echo starting release with versionInfo=${versionInfo}"
|
||||
if (versionInfo.isTag) {
|
||||
// upload to artifactory repository
|
||||
def server = Artifactory.server 'sw-gpu-artifactory'
|
||||
server.upload spec: uploadSpec
|
||||
} else {
|
||||
sh "echo skipping release for non-tagged build"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,35 +108,6 @@ def getGolangStages(def targets) {
|
||||
return stages
|
||||
}
|
||||
|
||||
def getSingleBuildForArchitectures(def architectures) {
|
||||
return getBuildStagesForArchitectures(architectures, "make", "ubuntu18.04")
|
||||
}
|
||||
|
||||
def getAllBuildForArchitectures(def architectures) {
|
||||
// TODO: For the time being we only echo the command for the "all" stages
|
||||
return getBuildStagesForArchitectures(architectures, "echo make", "docker")
|
||||
}
|
||||
|
||||
def getBuildStagesForArchitectures(def architectures, def makeCommand, def makeTargetPrefix) {
|
||||
stages = [:]
|
||||
|
||||
for (a in architectures) {
|
||||
stages[a] = getBuildClosure(a, makeCommand, "${makeTargetPrefix}-${a}")
|
||||
}
|
||||
|
||||
return stages
|
||||
}
|
||||
|
||||
def getBuildClosure(def architecture, def makeCommand, def makeTarget) {
|
||||
return {
|
||||
container('docker') {
|
||||
stage(architecture) {
|
||||
sh "${makeCommand} ${makeTarget}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getLintClosure(def target) {
|
||||
return {
|
||||
container('golang') {
|
||||
@ -104,3 +117,26 @@ def getLintClosure(def target) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getVersionInfo returns a hash of version info
|
||||
def getVersionInfo(def scmInfo) {
|
||||
def versionInfo = [
|
||||
isTag: isTag(scmInfo.GIT_BRANCH)
|
||||
]
|
||||
|
||||
scmInfo.each { k, v -> versionInfo[k] = v }
|
||||
return versionInfo
|
||||
}
|
||||
|
||||
def isTag(def branch) {
|
||||
if (!branch.startsWith('v')) {
|
||||
return false
|
||||
}
|
||||
|
||||
def version = shOutput('git describe --all --exact-match --always')
|
||||
return version == "tags/${branch}"
|
||||
}
|
||||
|
||||
def shOuptut(def script) {
|
||||
return sh(script: script, returnStdout: true).trim()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user