title: Integrate Artifactory into Jenkins Pipeline
body: <p>I am trying to integrate Artifactory into my Jenkins pipeline in order to push Maven artifacts to Artifactory. </p>
  
  <p>My current understanding is, that I should deploy the built Maven artifacts with using the Jenkins pipeline rather than through a Maven plugin during the <code>deploy</code> lifecycle of Maven.</p>
  
  <p>Based on the documentation that I have read so far I think I need code similar to this in my pipeline:</p>
  
  <pre><code>stage('Build') {
    steps {
      /** Start a docker container with maven and run mvn clean install */
    }
  }
  
  stage ('Deploy to Artifactory') {
    steps {
      script {
        def server = Artifactory.server 'my-server-id'
  
        def rtMaven = Artifactory.newMavenBuild()
  
        rtMaven.deployer.addProperty("status", "in-qa")
        buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean install'
        server.publishBuildInfo buildInfo
      }
    }
  }
  </code></pre>
  
  <p>However, I fail to completely understand what this is doing and I am unable to find more detailed documentation, execept for <a href="https://jfrog.com/blog/dont-let-maven-deploy-plugin-trip-you/" rel="nofollow noreferrer">this JFrog blog entry</a> and <a href="https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins" rel="nofollow noreferrer">this JFrog Confluence page</a>.</p>
  
  <p>In particular it seems that if I specify goals to the run directive it will run the Maven Pipeline again, which would not make much since the pipeline already ran in the first stage (e.g. 'Build').</p>
  
  <p>In addition I should note, that I am running the maven build inside a docker container, so it seems that using the above setup is not quite enough for me.</p>
  
  <p>Is there a best practice to approach this?</p>
  
  <p>What I am looking for is a way to collect the artifacts that I built with maven in my docker container and upload them to Artifactory without running maven again.</p>