Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40035

Artifactory GradleBuild does not work within docker.inside

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • artifactory-plugin
    • Jenkins 2.33 on CentOS 7 (master)
      CentOS 7 with Docker 1.12 (slave)
      Artifactory Jenkins Plugin 2.8.1
      Docker Pipeline Plugin 1.9.1
      Gradle 3.2

      The following Pipeline steps result in an error:

      docker.image(buildimage.imageName()).inside {
                def gradleBuildInfo = Artifactory.newBuildInfo()
                def rtGradle = Artifactory.newGradleBuild()
                rtGradle.resolver server: artifactory, repo: 'gradle-virtual'
                rtGradle.deployer server: artifactory, repo: 'gradle-virtual'
                rtGradle.setUseWrapper(true)
                rtGradle.deployer.setUsesPlugin(true)
                sh 'chmod +x ./gradlew'
                rtGradle.run rootDir: './', buildFile: 'build.gradle', tasks: 'clean resolve', buildInfo: gradleBuildInfo, switches: '--debug --no-daemon'
                sh './build.sh'
                buildInfo.append(gradleBuildInfo)
                buildInfo.env.collect
              }
      

      Jenkins output (debug output omitted):

      10:02:40.139 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] 
      10:02:40.142 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] BUILD SUCCESSFUL
      10:02:40.142 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] 
      10:02:40.143 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] Total time: 21.119 secs
      ERROR: Couldn't read generated build info at : /tmp/generated.build.info8459496679867578376.json
      

      When the steps are not enclosed in docker.inside everything works fine.
      My guess is that the Jenkins artifactory plugin creates files in the /tmp dir of the slave running the container instead of either using the workspace@tmp dir or the /tmp inside the container. After the gradle run the Jenkins plugin tries to read the file from /tmp in the container, where it was never created.
      We want to run multiple containers per slave so mounting the /tmp directory in the container is not possible.

            eyalbe Eyal Ben Moshe
            stefan_lengauer Stefan Lengauer
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: