简体   繁体   中英

Jenkins Artifactory Plugin

Can Jenkins Artifactory plugin run docker-in-docker? I would like to use this plugin in tandem with Jenkins Kubernetes plugin in a pipeline build provided below.

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

I suspect I am hitting this issue and just wanted to double check if it is still the case. When executed, the Artifactory plugin searches for resources, eg MAVEN_HOME, in the Pod instead of the maven container. Not being able to find the resources the plugin fails.

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()
    }
}

I've had the same problem and been trying various variations on configuring the connection to the maven installation.

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

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         
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM