Merge branch 'CNT-1334-publish-tags-to-artifactory' into 'master'

Add artifactory publish step

See merge request nvidia/container-toolkit/container-toolkit!30
This commit is contained in:
Evan Lezar 2021-05-18 17:25:07 +00:00
commit 825990ba41
2 changed files with 77 additions and 41 deletions

116
Jenkinsfile vendored
View File

@ -17,12 +17,15 @@
podTemplate (cloud:'sw-gpu-cloudnative',
containers: [
containerTemplate(name: 'docker', image: 'docker:dind', ttyEnabled: true, privileged: true),
containerTemplate(name: 'golang', image: 'golang:1.14.2', ttyEnabled: true)
containerTemplate(name: 'golang', image: 'golang:1.16.3', 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()
}

View File

@ -20,7 +20,7 @@ LIB_NAME := nvidia-container-toolkit
LIB_VERSION := 1.5.0
LIB_TAG ?=
GOLANG_VERSION := 1.14.2
GOLANG_VERSION := 1.16.3
GOLANG_PKG_PATH := github.com/NVIDIA/nvidia-container-toolkit/pkg
# By default run all native docker-based targets