commonLibFolder : Jenkins within docker

128 views
Skip to first unread message

ZT

unread,
May 16, 2016, 4:44:37 PM5/16/16
to Jenkins Users
I am trying to enhance the Jenkins classpath with custom additional jars.

While i am aware that we can include it through the additional classpath of groovy plugins . I am currently looking for a more generic option so i can run the jar code through jenkins scripting console (besides regular jobs) as well.

In a non docker environment, augmenting JENKINS_ARGS="--commonLibFolder={filePath}"  while starting jenkins works.

However, when i give the following line in my dockerfile (extending  jenkins docker image)

ENV JENKINS_ARGS --commonLibFolder={filePath}.

This doesn't work. When i try to load a class from the jar i get a failure saying the class cannot be resolved.

Has anyone got this to work within docker? Or any other pointers to accomplish this? 

Thanks for your help

ZT

Baptiste Mathus

unread,
May 18, 2016, 11:58:04 AM5/18/16
to jenkins...@googlegroups.com

IIUC your issue has just to do with the fact the file you're passing is located on the host, hence not accessible to the container.
So, you're left with two options:
* the right one: inherit the official image and customize it with a dedicated Dockerfile
* the quick and dirty one: bind mount the file you need (using -v) so that it can be found when the Jenkins container starts. Note that you want to avoid docker bind-mounts in general, so IMO this solution would possibly only be used for quickly PoCing what you want.

Cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e2c7a120-b305-419f-8768-5cb6803b3899%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ZT

unread,
Jul 24, 2016, 7:48:15 PM7/24/16
to Jenkins Users
sorry for the delay, i got tied up with workarounds but this continues to be an issue.

My goal is to load some custom jars into Jenkins so I am mounting this directory already.

When i use docker-compose

I have to do something like
docker-compose run -d --commonLibFolder={libDirectoryLocation} << This works perfectly

I looked into this a bit and jenkins sets this as sun.java.command, so in the jenkins system information page , i can see
sun.java.command /usr/share/jenkins/jenkins.war --commonLibLocation={libDirectoryLocation}

I am trying to find an alternate way to do this, so that i don't have to type in such a big command (one of the purposes of docker compose)

I have tried a few things
- Environment variables(sun.java.command) - This creates a second entry and does not work
- JENKINS_OPTS , JENKINS_ARGS (i have used this approach outside docker to customize classpath)

Nothing seems to work, i am sure i am am missing something but i can't figure out what..


ZT

unread,
Jul 24, 2016, 7:48:16 PM7/24/16
to Jenkins Users

tzach solomon

unread,
Feb 7, 2024, 11:25:44 AMFeb 7
to Jenkins Users
What worked for me is environment variable JENKINS_OPTS liek this JENKINS_OPTS=--commonLibFolder=/root/my_jars/
Reply all
Reply to author
Forward
0 new messages