Hi guys! I hope this is the right place to ask... ...
# gradle
d
Hi guys! I hope this is the right place to ask... If I have a Jenkins pipeline building my Kotlin (Ktor) project using Gradle, how do I keep the build artifact cache from build to build (the Jenkins slave is always on the same node). I'm currently running:
docker run --rm -v "$PWD":/home/gradle/project -w /home/gradle/project gradle:4.5.1-jdk8-alpine gradle shadowJar --no-daemon --console plain
?
g
Just attach ~/.gradle dir to volume
👍🏼 1
d
Nope, I tried
docker run --rm -v /home/gradle/.gradle -v "$PWD":/home/gradle/project -w /home/gradle/project gradle:4.5.1-jdk8-alpine gradle shadowJar --no-daemon --console plain
, no go... am I getting something wrong? Base image
FROM openjdk:8-jre-alpine
...?
g
Hmm, not sure how --rm works, mayb it removes also associated volumes without mapping. Try explicitly connect volume to some local dir to check this:
Copy code
-v /my/gradle/cache:/home/gradle/.gradle
also check that gradle acutally uses
/home/gradle/.gradle
as home dir
d
Gradle gave me:
Failed to load native library 'libnative-platform.so' for Linux amd64.
For:
Copy code
sh 'chown -R 1000:1000 .'
        sh 'mkdir -p /tmp/.gradle; chown -R 1000:1000 /tmp/.gradle'
        sh 'docker run --rm -v "/tmp/.gradle":/home/gradle/.gradle -v "$PWD":/home/gradle/project -w /home/gradle/project gradle:4.5.1-jdk8-alpine gradle shadowJar --no-daemon --console plain'
I thought it had to do w/ dir. permissions, so I added
chown
on tmp...
at /home/gradle/.gradle
You were right about --rm, though: https://github.com/moby/moby/issues/23023
But even when I named the volume, still no go...
g
since there’s a VOLUME in the image itself
Right, but not named, so volume deleted
what is your problem now? do you see dependencies inside your local dir when you connected it as volume?
d
Now it's fine...
docker run --rm -v gradle-cache:/home/gradle/.gradle -v "$PWD":/home/gradle/project -w /home/gradle/project gradle:4.7.0-jdk8-alpine gradle shadowJar --no-daemon --console plain
! Thanks for the help 😃
g
👍