-
Improvement
-
Resolution: Unresolved
-
Major
-
None
It would be nice to provide integration between the Artifactory Plugin and the Docker Workflow plugin:
https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#docker-workflow
I tried to see if it will work out of the box but it does not. Here's my pipeline code extract:
docker.image(dockerImageName).inside { def mirrorServer = Artifactory.newServer url: 'http://.....' def artifactoryServer = Artifactory.server('my-artifactory') def rtMaven = Artifactory.newMavenBuild() rtMaven.resolver server: mirrorServer, releaseRepo: 'XXX', snapshotRepo: 'XXXX' rtMaven.deployer server: artifactoryServer, releaseRepo: 'repository-release', snapshotRepo: 'repository' String localMavenRepo = env.WORKSPACE + '/local_maven_repo/' rtMaven.opts = mavenOpts rtMaven.tool = 'DOCKER_BUILDER_CONTAINER_MAVEN_TOOL' mavenGoals = mavenGoals + "${mavenProjectsToBuild} ${mavenProfiles} ${mavenAdditionalCommandLineOptions} -Dmaven.repo.local=${localMavenRepo}" String pomLocation = "${checkoutFolder}/pom.xml" def buildInfo = rtMaven.run pom: pomLocation, goals: mavenGoals artifactoryServer.publishBuildInfo buildInfo }
- First problem that i hit was related to the the MAVEN tool setting (rtMaven.tool)
-
- The Docker Workflow plugin will execute any external command like "sh" inside the container but the artifactory plugin looks for the maven install via some other way so it ends up looking on the docker host.
- So i just unzipped maven in the same location on the docker host as inside the container and i was able to get pass this error by also creating a jenkins MAVEN TOOL entry that points to the maven home :
DOCKER_BUILDER_CONTAINER_MAVEN_TOOL
- The next problem and the current blocker is when the build starts:
$ docker run -t -d -u 10001:10001 -w /jenkins_slave/workspace/kuku -v /jenkins_slave/workspace/kuku:/jenkins_slave/workspace/kuku:rw -v /jenkins_slave/workspace/kuku@tmp:/jenkins_slave/workspace/kuku@tmp:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat builder-centos-7.3.1611-maven-3.5-jdk-7:2.0.0 [Pipeline] ArtifactoryMavenBuild Jenkins Artifactory Plugin version: 2.11.0 Artifactory integration is enabled docker exec e739136dfe42725ce2311d622cbb5717a2f97672afa5ad744aa4cda73ff5737d env BUILDINFO_PROPFILE=/tmp/buildInfo2776540797318816891.properties BUILD_DISPLAY_NAME=#11 BUILD_ID=11 BUILD_NUMBER=11 BUILD_TAG=jenkins-kuku-11 BUILD_URL=xxxxxxx CLASSPATH= EXECUTOR_NUMBER=0 HUDSON_HOME=/var/jenkins_home HUDSON_SERVER_COOKIE=xxxxxxx HUDSON_URL=http://........ JENKINS_HOME=/var/jenkins_home JENKINS_SERVER_COOKIE=xxxxxxx JENKINS_URL=xxxxxxxx JOB_BASE_NAME=kuku JOB_DISPLAY_URL=xxxxxx JOB_NAME=kuku JOB_URL=xxxxxx "NODE_LABELS=xxxxxx" NODE_NAME=xxxxx RUN_CHANGES_DISPLAY_URL=xxxxxx RUN_DISPLAY_URL=xxxxxx WORKSPACE=/jenkins_slave/workspace/kuku buildInfoConfig.propertiesFile=/tmp/buildInfo2776540797318816891.properties extractor.used=true generated.build.info=/tmp/generated.build.info4184088342318554445.json library.mylib.version=artifactoryTest java -classpath /opt/maven/boot/plexus-classworlds-2.5.2.jar -Dmaven.home=/opt/maven -DbuildInfoConfig.propertiesFile=/tmp/buildInfo2776540797318816891.properties -Dm3plugin.lib=/jenkins_slave/cache/artifactory-plugin/2.11.0 -Dclassworlds.conf=/tmp/classworlds8955451495094415553conf -Dmaven.multiModuleProjectDirectory=/jenkins_slave/workspace/kuku -Xmx1024m -XX:MaxPermSize=128m org.codehaus.plexus.classworlds.launcher.Launcher -f /jenkins_slave/workspace/kuku/xxxxx/pom.xml clean install -Dmaven.repo.local=//jenkins_slave/workspace/kuku/local_maven_repo/ java.io.FileNotFoundException: /tmp/classworlds8955451495094415553conf (No such file or directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:146) at java.io.FileInputStream.<init>(FileInputStream.java:101) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:390) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
As you can see the build itself is started inside the container but all /tmp/xxxx folders above exist on the docker host instead inside the container (assume they are created as part of the artifactory plugin initialization process)
I do not see another way of accomplishing this task hence I'm submitting the feature request as i think it will be awesome if these two plugins can work together!
Thanks
Actually i have a workaround but it's kind of ugly:
docker.image(dockerImageName).inside("-v /tmp:/tmp:rw -v /jenkins_slave/cache/artifactory-plugin/2.11.0:/jenkins_slave/cache/artifactory-plugin/2.11.0") { ..... }
The above exposes the /tmp and /jenkins_slave/cache/artifactory-plugin/2.11.0 inside the container and this fixes the problem. But the stuff in /tmp/ should remain in the container only (so that when the build is over and the container is deleted the stuff in /tmp/ is also gone).
Not sure about the jars in /jenkins_slave/cache/artifactory-plugin/2.11.0. **The size of the folder on my setup is 29 MB so downloading this on every build is probably a waste so this volume should also be mounted inside the container (automatically).
Thanks