Jenkins Pipeline job can't find script due to @tmp path being created
I was having the same issue. I think @Oren technically answered your question about why Jenkins creates this tmp
space, but I can share some info about how I solved it.
Basically, my Jenkins host symlinks bin/sh
to dash
; not bash
. So, using a POSIX-compliant shell script solved the issue for me.
For example, I was trying to use shopt -s extglob
to do some pattern matching:
stage { def shellCommand = $/ "rm -rf ! (_data|_includes|_plugins|Gemfile|_config.yml|page-builder)"/$ sh(returnStdout: true, script: shellCommand).trim()}
Since dash
doesn't support extglob
, replacing that with a POSIX-compliant find
command worked:
stage { sh('find . -regextype posix-extended -not -regex ".*includes.*|.*data.*|.*plugins.*|.*config.yml|.*Gemfile.*"')}