0
votes

We have artifactory pro and We need to know if We can promote an artifact from Jenkins through the plugin. Currently, We are deploying on artifactory and when We need promote first, We download the artifact from artifactory to jenkins and then We publish it on artifactory with other tag.

Exists some way to promote from Jenkin’s pipeline without API, because we need a solution that not expose our credentials.

Thanks,

1
Of which "plugin" are you talking? The artifactory plugin has a artifactoryPromoteBuild step. Not sure, if this is what you're searching for. - StephenKing
@StephenKing I'm talking about The artifactory plugin, the problem is that the step of artifactoryPromoteBuild is a manual step, I can´t configure it as a step into a job. - Camila Naranjo

1 Answers

1
votes

You can promote a build inside a jenkins script by using artifactory.promote instead of Artifactory.addInteractivePromotion as shown:

@NonCPS
def promote(artifactory, buildInfo) {
    echo "currentBuild.result is ${currentBuild.result}"
    def QAPromotionConfig = [
            'buildName'   : buildInfo.name,
            'buildNumber' : buildInfo.number,
            'targetRepo'  : 'debian-local-qa',
            'sourceRepo'  : 'debian-local-debug',
            'copy'        : true
    ]
    def RelPromotionConfig = [
            'buildName'   : buildInfo.name,
            'buildNumber' : buildInfo.number,
            'targetRepo'  : 'debian-local-release',
            'sourceRepo'  : 'debian-local-debug',
            'copy'        : true
    ]
    if(currentBuild.result == "SUCCESS") {
        artifactory.promote(QAPromotionConfig)
    } else {
        Artifactory.addInteractivePromotion(server: artifactory, promotionConfig: QAPromotionConfig, displayName: "Promote to QA")
    }
    Artifactory.addInteractivePromotion(server: artifactory, promotionConfig: RelPromotionConfig, displayName: "Promote to Release")
}