4
votes

I am archiving artifacts at the end of each build. I have https://wiki.jenkins-ci.org/display/JENKINS/Archived+Artifact+Url+Viewer+PlugIn installed. Thought the plugin says artifacts can be viewed here

"/archivedArtifacts/artifact/job_name/build_number/relative location of zip or jarfile within artifact folder/location of file within archive Ex:

http://jenkins_url/archivedArtifacts/artifact/Build%20-%20Dev/10526/junit-logs.zip/junit.log"

I am unable to see artifacts using this URL

http://localhost:8080/archivedArtifacts/artifact/TestFirstJob/32/target/MavenTest-0.0.1-SNAPSHOT.jar

I do not have any "artifact" folder. I do have archive folder in the inside each build number.

I can see artifacts of the last build on the respective job homepage.

Any help to view artifacts using this URL is appreciated. Also, Is there a way I can view all of the artifacts build so far at one place.

1

1 Answers

1
votes

Archive is how to save files outside workspace. We can clean our workspace, run other builds and the file archived is still safe.

For do that is simple, only with one command we can artifact our files.

archiveArtifacts artifacts: 'file.extension'

For example:

pipeline {
    agent any
    
    stages {
        stage('Download') {
            steps {
                sh 'echo "artifact file" > generatedFile.txt'
            }
        }
    }
    post {
        always {
            archiveArtifacts artifacts: 'generatedFile.txt', onlyIfSuccessful: true
        }
    }
}

Once we build the pipeline and it is successfull, we can find our artifact in either of the following locations:

  • $JENKINS_HOME/yourjobname/branches/branchname/builds/yourbuildernumer/archive
  • $JENKINS_HOME/yourjobname/builds/yourbuildernumer/archive