I have a shell script that is common for many projects in side Jenkins, is it correct to put it into the resources folder and load it as below:
def script = libraryResource 'build/package_indexes/build_push.sh'
while this works:
sh script
but once I start making the build_push.sh
script to accept arguments, it won't work since script
is not a file...
Second question is that is it correct to output that script
variable into a temp file such as
writeFile script '/tmp/tmp.sh'
sh "/tmp/tmp.sh 'cmd_arg'"
bash -c
will do the trick. just remember that the first param is $0 and not $1for example:
my script -
in Jenkinsfile
and the result is hello world!