Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

352
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda