I am going through a jenkins pipeline someone else did for my organization. I saw inside that jenkins pipeline it has called to a external groovy script but I have no idea about that process. This is how it has been called.
sh "groovy -cp /apps/scripts /apps/scripts/BuildReport.groovy ${env.BUILD_URL} ${env.BUILD_ID}"
I know ${env.BUILD_URL} ${env.BUILD_ID}
are the arguments that has been passed to the groovy script. But what is the meaning of groovy -cp
?
and why /apps/scripts
has mentioned two times?
can someone clear please..? Thanks in advance..!
CodePudding user response:
The sh
command is using the Groovy installation of your Jenkins Agent. -cp
argument specifies the classpath
, this is where your additional dependencies will reside. For example, if BuildReport.groovy
requires additional dependencies you can point to a directory where the additional dependencies are located. The following is from the groovy man pages.
-cp, -classpath, --classpath=<path>
Specify where to find the class files - must be
first argument
Having said that, in your case, if you don't have any dependent Classes, specifying the classpath would be redundant.