Viktor Be
Viktor Be

Reputation: 788

Jenkins Artifacts from parallel Jobs

Which Artifacts do Jenkins archive using archiveArtifacts if a job is running parallel jobs on different nodes?

matrix {
    axes {
        axis {
            name 'PLATFORM'
            values 'linux', 'mac', 'windows'
        }
    }
    agent {label 'PLATFORM'}
    stages {
        stage('build-and-test') {
            // create artifacts in env.WORKSPACE/delivery/
            archiveArtifacts artifacts: env.WORKSPACE + 'delivery/**'
        }
    }
}

In this case there could be identical or different artifacts with same names. Do Jenkins store all of them? Which artifacts are we going to see on the Jobs page under "Last Successful Artifacts"?

Upvotes: 3

Views: 1962

Answers (1)

MaratC
MaratC

Reputation: 6889

You won't get everything, and as far as I remember, Jenkins will override the artifacts, so stages that request to archive e.g. "tests.xml" will be in race, the winner being the last one to the finish line.

We move the artifacts to a unique folder before archiving, e.g.

...
script {
    sh label: "Moving artifacts to ${testName}",
        script: """rm -rf ${env.WORKSPACE}/${testName} || true
            mkdir ${env.WORKSPACE}/${testName}
            mv ${env.WORKSPACE}/tests.xml ${env.WORKSPACE}/${testName}/"""

    archiveArtifacts artifacts: "${testName}/**" 
}

Upvotes: 3

Related Questions