title: What is the best practice for archiving Jenkins pipeline artifacts
body: <p>I see that you can add a goal to a maven Pom to archive artifacts to a repo manager such as nexus</p>
  
  <p><a href="https://www.baeldung.com/maven-deploy-nexus" rel="nofollow noreferrer">https://www.baeldung.com/maven-deploy-nexus</a></p>
  
  <pre><code>distributionManagement&gt;
     &lt;snapshotRepository&gt;
        &lt;id&gt;nexus-snapshots&lt;/id&gt;
        &lt;url&gt;http://localhost:8081/nexus/content/repositories/snapshots&lt;/url&gt;
     &lt;/snapshotRepository&gt;
  &lt;/distributionManagement&gt;
  </code></pre>
  
  <p>But Jenkins also allows you to do this from the pipeline itself</p>
  
  <p><a href="https://wiki.jenkins.io/plugins/servlet/mobile?contentId=96076078#content/view/96076078" rel="nofollow noreferrer">https://wiki.jenkins.io/plugins/servlet/mobile?contentId=96076078#content/view/96076078</a></p>
  
  <pre><code>freeStyleJob('NexusArtifactUploaderJob') {
      steps {
        nexusArtifactUploader {
          nexusVersion('nexus2')
          protocol('http')
          nexusUrl('localhost:8080/nexus')
          groupId('sp.sd')
          version('2.4')
          repository('NexusArtifactUploader')
          credentialsId('44620c50-1589-4617-a677-7563985e46e1')
          artifact {
              artifactId('nexus-artifact-uploader')
              type('jar')
              classifier('debug')
              file('nexus-artifact-uploader.jar')
          }
          artifact {
              artifactId('nexus-artifact-uploader')
              type('hpi')
              classifier('debug')
              file('nexus-artifact-uploader.hpi')
          }
        }
      }
  }
  </code></pre>
  
  <p>What is the difference between the two approaches, is one more commonly used?</p>