ARTIFACTORY: How to aggregate builds in Jenkins with the Jenkins JFrog Plugin

AuthorFullName__c
Yonatan Hen
articleNumber
000005596
FirstPublishedDate
2023-03-01T17:51:56Z
lastModifiedDate
2025-07-20

ARTIFACTORY: How to aggregate builds in Jenkins with the Jenkins JFrog Plugin

Publishing buildInfo generated with many sub-builds or as part of a multi-agent build has some limitations (with the Jenkins Artifactroy Plugin), and in order to fix this, we can use the new Jenkins JFrog Plugin which relies on JFrog CLI commands.

According to our documentation, the desired results should be obtained by creating a separate build-info for every section of the build and publishing it independently to Artifactory. Once all the build-info instances are published, you can create a new build-info, which references all the previously published build-info instances. The new build-info can be viewed as a “master” build-info, which references other build-info instances.

The script example below can be used as a reference and modified according to your requirements. Please make sure you have the Jenkins JFrog Plugin installed and configured on your Jenkins server. 
 

pipeline {
    agent any
    tools {
        jfrog 'jfrog-cli'
    }
    stages {
        stage('Create build info') {
            steps {
       // The values of the parameters in the flags are used as an example, not mandatory
                jf 'rt bdi "ci-pipeline" --max-builds=2 --max-days=2 --delete-artifacts=true'
            }
        }
        stage ('Upload1') {
            steps {
                // Create a file and upload it to a repository named 'ci-testing' in Artifactory
                sh 'touch test-file1'
                jf 'rt u test-file1 ci-testing/ --build-name a --build-number 1'
        // Create a build with the name of ‘a’, version 1
                jf 'rt build-publish a 1'
            }
        }
        stage ('Upload2') {
            steps {
                // Create a file and upload it to a repository named 'ci-testing' in Artifactory
                sh 'touch test-file2'
                jf 'rt u test-file2 ci-testing/ --build-name b --build-number 1'
        // Create a build with the name of ‘b’, version 1
                jf 'rt build-publish b 1'
            }
        }
        stage ('Aggregate Builds') {
            steps {
       // Aggregate the ‘a’ & ‘b’ builds under the ‘‘aggregating-build’ build
                jf 'rt build-append aggregating-build 10 a 1'
                jf 'rt build-append aggregating-build 10 b 1'
            }
        }
        stage ('Publish Build info') {
            steps {
                // Publish the build-info to Artifactory.
                jf 'rt bp aggregating-build 10'
            }
        }
    }
}



The following are the predicted outcomes:
 User-added image

 The aggregated builds should be seen in the Artifactory instance as follows:

User-added imageUser-added image

User-added imageUser-added image