Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

351
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda