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")
}
artifactoryPromoteBuildstep. Not sure, if this is what you're searching for. - StephenKing