Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

350
Views
Jenkinsfile maven plugin inside a docker container

I'm using Jenkins with a Jenkinsfile that runs my builds inside a docker container. I have a simple Java application that I'd like to build and deploy to artifactory using the Jenkins Artifactory plugin.

My Jenkinsfile is below -

node {
  def server = Artifactory.server "my-artifactory"
  def rtMaven = Artifactory.newMavenBuild()

  stage("Prepare environment"){
    docker.image('driv/docker-maven-java-oracle').inside {

      checkout scm

      stage("Artifactory configuration") {
        rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server
        rtMaven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server
      }

      stage("Maven build") {
        def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean install'
      }
    }
  }
}

However, when I run builds with the above Jenkinsfile I get the error -

java.lang.RuntimeException: Couldn't find maven installation

I know that I can add a line to my Jenkinsfile like this -

rtMaven.tool = MAVEN_TOOL

...that I can use to specify a pre-configured Jenkins Tool to point the Artifactory plugin at Maven. However, it seems to me that such a pre-configured tool would have to be on the Jenkins machine, or a build node, and not inside my docker container.

So, is it possible to point the Artifactory plugin at a maven installation inside my docker container?

Thanks.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This should probably be fixed in their jenkins plugin itself but as "Christopher Orr" suggested mapping environment vars at the pipeline stage level to the same ones set in the container work

For example

stage('mystage') {
    environment {
        // If your using the official maven image, these are probably where it puts it
        MAVEN_HOME = '/usr/share/maven'
        JAVA_HOME= '/usr/local/openjdk-8'
    }
    steps {
        sh """
            # confirm location of MAVEN_HOME and JAVA_HOME in container and set in environment directive
            printenv 
        """
        ...
        // call rtMavenRun()
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!