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

356
Views
Jenkinsfile maven plugin dentro de un contenedor docker

Estoy usando Jenkins con un Jenkinsfile que ejecuta mis compilaciones dentro de un contenedor docker. Tengo una aplicación Java simple que me gustaría compilar e implementar en el artefacto usando el complemento Jenkins Artifactory.

Mi Jenkinsfile está debajo -

 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' } } } }

Sin embargo, cuando ejecuto compilaciones con el Jenkinsfile anterior, aparece el error:

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

Sé que puedo agregar una línea a mi Jenkinsfile así:

 rtMaven.tool = MAVEN_TOOL

... que puedo usar para especificar una herramienta Jenkins preconfigurada para apuntar el complemento Artifactory a Maven. Sin embargo, me parece que dicha herramienta preconfigurada debería estar en la máquina Jenkins, o en un nodo de compilación, y no dentro de mi contenedor docker.

Entonces, ¿es posible apuntar el complemento Artifactory a una instalación experta dentro de mi contenedor docker?

Gracias.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Esto probablemente debería solucionarse en su complemento jenkins, pero como "Christopher Orr" sugirió mapear las variables del entorno en el nivel de etapa de la tubería a las mismas establecidas en el trabajo del contenedor.

Por ejemplo

 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()
over 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!