Reputation: 33
I have a Jenkins pipeline to build a .deb package. It successfully uploads the package to an Artifactory repository. The package itself is in the 'pool', and the metadata are created for the 'main' component and the 'testing' distribution. My preprod environment installs the package via APT.
What I would like to do now is to promote the build to the 'stable' distribution in the same repository (we have only one corporate Artifactory instance with lots of repositories, so I can't have several).
My pipeline looks like this:
#!/usr/bin/env groovy
node('XXX') {
def artifactoryServer
def artifactoryBuildInfo
stage('Artifactory configuration') {
artifactoryServer = Artifactory.newServer url: "http://mycorporateartifactoryrepo.com", credentialsId: 'XXXXX'
}
stage('checkout') {
checkout scm
}
stage('packaging & deploying') {
artifactoryBuildInfo = Artifactory.newBuildInfo()
// Packaging & deploying mvn
archiveArtifacts artifacts: "target/cowsay.deb", fingeprint: true
// packaging & deploying deb package
def uploadSpec = """{
"files": [
{
"pattern": "target/cowsay.deb",
"target": "debian-repo/pool/",
"props": "deb.distribution=testing;deb.component=main;deb.architecture=all"
}
]
}"""
artifactoryBuildInfo = artifactoryServer.upload spec: uploadSpec
artifactoryServer.publishBuildInfo artifactoryBuildInfo
}
stage('promotion') {
def promotionConfig = [
'buildName' : artifactoryBuildInfo.name,
'buildNumber' : artifactoryBuildInfo.number,
'sourceRepo' : 'debian-repo/pool/',
'targetRepo' : 'debian-repo/pool/',
'comment' : 'Promoting build',
'status' : 'Released',
'includeDependencies': true,
'copy' : true,
'failFast' : true
]
// Promote build interactively if tests are OK
Artifactory.addInteractivePromotion server: artifactoryServer, promotionConfig: promotionConfig, displayName: 'Promote me!'
}
}
How can I manage this? Artifactory does not document such a possibility. Do I need to create a custom pipeline to achieve this?
Thanks
Upvotes: 2
Views: 772
Reputation: 2709
Artifactory Build Promotion gives you the ability to mark a build as 'promoted' (i.e. released) and perhaps move or copy Artifacts to different repos (which signify a release-ready location).
In your case though, changing a Debian artifact's distribution can be done by modifying the deb.distribution
property set on the artifact - this will cause it to get indexed in stable
distribution as well (and thus available to apt in the new distribution).
I would suggest either adding a step to your pipeline for this or creating a different job altogether that promotes the build and then annotates the artifacts with the required properties.
Another alternative is to use a user plugin that you can trigger from your job, but tagging with properties is more convenient via standard REST API IMHO.
Upvotes: 1