<p>Can Jenkins <a href="https://wiki.jenkins.io/pages/viewpage.action?pageId=101023746" rel="nofollow noreferrer">Artifactory plugin</a> run docker-in-docker? I would like to use this plugin in tandem with Jenkins <a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow noreferrer">Kubernetes plugin</a> in a pipeline build provided below.</p>

<p>The example pipeline creates a Pod which firstly uses a <code>git</code> container to clone the given <code>project-examples</code> repository and then uses a <code>maven</code> container to build the project. </p>

<p>I suspect I am hitting <a href="https://www.jfrog.com/jira/browse/HAP-982" rel="nofollow noreferrer">this</a> issue and just wanted to double check if it is still the case.
When executed, the Artifactory plugin searches for resources, e.g. MAVEN_HOME, in the Pod instead of the <code>maven</code> container. Not being able to find the resources the plugin fails.</p>

<pre><code>def label = "worker-${UUID.randomUUID().toString()}"

podTemplate(label: label, containers: [
  containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'),
  containerTemplate(name: 'git', image: 'alpine/git', command: 'cat', ttyEnabled: true)
]) {
  node(label) {

container('maven') {
    def server
    def buildInfo
    def rtMaven


    stage ('Clone') {
        git url: 'https://github.com/jfrogdev/project-examples.git'
    }

    stage ('Test a Maven project') {           
            server = Artifactory.server 'private-artifactory'
            rtMaven = Artifactory.newMavenBuild()
            rtMaven.tool = 'maven'
            rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean build', buildInfo: buildInfo
            buildInfo = Artifactory.newBuildInfo()
    }
}
</code></pre>

Gin
<p>I've had the same problem and been trying various variations on configuring the connection to the maven installation.</p>

<p>The final configuration that seems to be working in picking up the maven installation that I have in my docker image is as follows:</p>

<pre><code>stage("build") {
   def server=Artifactory.server('My art')
   def rtMaven=Artifactory.newMavenBuild()
   rtMaven.resolver server: server, releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot'
   rtMaven.deployer server: server, releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local'
   env.MAVEN_HOME="/usr/share/maven"
   def buildInfo = rtMaven.run pom: 'sub-dir/pom.xml', goals: 'clean install'
   server.publishBuildInfo buildInfo         
}
</code></pre>

<p>Using env.MAVEN_HOME instead of relying on a tool configuration seems to work. Rembember to place it before <strong>rtMave.run</strong>.</p>
