Skip to content

Commit

Permalink
chore: add commit metadata to artifactory package props
Browse files Browse the repository at this point in the history
Refs: IN-718
  • Loading branch information
DanielePeruzzi97 authored and M0Rf30 committed Sep 5, 2024
1 parent 5d83c48 commit 0698170
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def getRpmSpec(String upstream, String version) {
}

def generateRpmSpec(String packageName, String version, String upstream) {
return '''{
return """{
"pattern": "artifacts/x86_64/(''' + packageName + ''')-(*).el''' + version + '''.x86_64.rpm",
"target": "''' + upstream + '''/zextras/{1}/{1}-{2}.el''' + version + '''.x86_64.rpm",
"props": "rpm.metadata.arch=x86_64;rpm.metadata.vendor=zextras"
"props": "rpm.metadata.arch=x86_64;rpm.metadata.vendor=zextras;vcs.revision=${env.GIT_COMMIT}"
}
'''
"""
}

def buildRpmPackages(String flavor) {
Expand Down Expand Up @@ -96,6 +96,9 @@ pipeline {
withCredentials([file(credentialsId: 'jenkins-maven-settings.xml', variable: 'SETTINGS_PATH')]) {
sh "cp ${SETTINGS_PATH} settings-jenkins.xml"
}
script {
env.GIT_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
}
}
}
stage('Build') {
Expand Down Expand Up @@ -275,24 +278,24 @@ pipeline {
def buildInfo
def uploadSpec
buildInfo = Artifactory.newBuildInfo()
uploadSpec ='''{
uploadSpec ="""{
"files": [{
"pattern": "artifacts/*focal*.deb",
"target": "ubuntu-devel/pool/",
"props": "deb.distribution=focal;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=focal;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},
{
"pattern": "artifacts/*jammy*.deb",
"target": "ubuntu-devel/pool/",
"props": "deb.distribution=jammy;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=jammy;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},
{
"pattern": "artifacts/*noble*.deb",
"target": "ubuntu-devel/pool/",
"props": "deb.distribution=noble;deb.component=main;deb.architecture=amd64"
},''' + getRpmSpec("centos8-devel", "8") + ''',''' + getRpmSpec("rhel9-devel", "9") + '''
"props": "deb.distribution=noble;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},""" + getRpmSpec("centos8-devel", "8") + """,""" + getRpmSpec("rhel9-devel", "9") + """
]
}'''
}"""
server.upload spec: uploadSpec, buildInfo: buildInfo, failNoOp: false
}
}
Expand All @@ -317,24 +320,24 @@ pipeline {
def buildInfo
def uploadSpec
buildInfo = Artifactory.newBuildInfo()
uploadSpec ='''{
uploadSpec ="""{
"files": [{
"pattern": "artifacts/*focal*.deb",
"target": "ubuntu-playground/pool/",
"props": "deb.distribution=focal;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=focal;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},
{
"pattern": "artifacts/*jammy*.deb",
"target": "ubuntu-playground/pool/",
"props": "deb.distribution=jammy;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=jammy;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},
{
"pattern": "artifacts/*noble*.deb",
"target": "ubuntu-playground/pool/",
"props": "deb.distribution=noble;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=noble;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},
''' + getRpmSpec("centos8-playground", "8") + ''',''' + getRpmSpec("rhel9-playground", "9") + ''']
}'''
""" + getRpmSpec("centos8-playground", "8") + """,""" + getRpmSpec("rhel9-playground", "9") + """]
}"""
server.upload spec: uploadSpec, buildInfo: buildInfo, failNoOp: false
}
}
Expand All @@ -361,23 +364,23 @@ pipeline {
//ubuntu
buildInfo = Artifactory.newBuildInfo()
buildInfo.name += '-ubuntu'
uploadSpec = '''{
uploadSpec = """{
"files": [{
"pattern": "artifacts/*focal*.deb",
"target": "ubuntu-rc/pool/",
"props": "deb.distribution=focal;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=focal;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},
{
"pattern": "artifacts/*jammy*.deb",
"target": "ubuntu-rc/pool/",
"props": "deb.distribution=jammy;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=jammy;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
},
{
"pattern": "artifacts/*noble*.deb",
"target": "ubuntu-rc/pool/",
"props": "deb.distribution=noble;deb.component=main;deb.architecture=amd64"
"props": "deb.distribution=noble;deb.component=main;deb.architecture=amd64;vcs.revision=${env.GIT_COMMIT}"
}]
}'''
}"""
server.upload spec: uploadSpec, buildInfo: buildInfo, failNoOp: false
config = [
'buildName': buildInfo.name,
Expand All @@ -396,9 +399,9 @@ pipeline {
//centos8
buildInfo = Artifactory.newBuildInfo()
buildInfo.name += '-centos8'
uploadSpec = '''{
"files": [''' + getRpmSpec("centos8-rc", "8") + ''']
}'''
uploadSpec = """{
"files": [""" + getRpmSpec("centos8-rc", "8") + """]
}"""
server.upload spec: uploadSpec, buildInfo: buildInfo, failNoOp: false
config = [
'buildName': buildInfo.name,
Expand All @@ -417,10 +420,10 @@ pipeline {
//rhel9
buildInfo = Artifactory.newBuildInfo()
buildInfo.name += '-rhel9'
uploadSpec = '''{
"files": [''' + getRpmSpec("rhel9-rc", "9") + '''
uploadSpec = """{
"files": [""" + getRpmSpec("rhel9-rc", "9") + """
]
}'''
}"""
server.upload spec: uploadSpec, buildInfo: buildInfo, failNoOp: false
config = [
'buildName': buildInfo.name,
Expand Down

0 comments on commit 0698170

Please sign in to comment.