timmy timmy - 2 months ago 20
Bash Question

What does copy-reference-file in find ... -exec bash -c ". jenkins-support; copy_reference_file '{}'" \; do?

Can someone explain what the following command does?

find /usr/share/jenkins/ref/ -type f -exec bash -c ". /usr/local/bin/jenkins-support; copy_reference_file '{}'" \;


In the above example, what would
copy_reference_file
refer to?

Answer

This recursive find does:

  • starting in /usr/share/jenkins/ref/ and in all of its subdirectories:
  • for every regular file (that is, files that are not symlinks, directories, devices, etc) found:
  • after sourcing the file /usr/local/bin/jenkins-support (to set environment variables or otherwise modify the execution environment):
  • run the command copy_reference_file against each file you found

I'm guessing that this probably copies in prerequisites for a build run before actually running the build. Google is replete with failures of this command, mostly around Docker and how volumes get mounted when jenkins is running.

As in most things UNIX, any issues are either case (upper/lower), path (where a file is), or permissions. Any issues you see are probably the latter.

EDIT: As a reference, I've pasted the relevant content of /usr/local/bin/jenkins-support on pastebin. Looks like it mostly slings around Jenkins components such as plugins. This exact line appears to come from the the main Jenkins startup script in the Docker image.