在Jenkins管道运行bash脚本时,权限被拒绝



团队,当试图通过jenkins管道运行脚本时,权限被拒绝任何线索可能是shell脚本不被执行的原因?我尝试了所有我能尝试的组合。仍然看. .我把这777个烫发都烫了。我照做了,但运气不好。

/home/jenkins/代理/workspace/团队/code-coverage-WIP@tmp/durable-29cd82d6/script.sh:4://: Permission denied

steps {
preBuild(bazel_init)
container('main') {
sh '''
pwd
ls -ltr
ls -ltr scripts/test-report.sh
chmod 777 scripts/test-report.sh
ls -ltr scripts/test-report.sh
BAZEL_OPTS="--config=ci --config=remote_cache_ci"
scripts/test-report.sh
'''.stripIndent()

输出
+ ls -ltr scripts/test-report.sh
-rwxr-xr-x 1 jenkins jenkins 238 Dec 9 06:18 scripts/test-report.sh
+ chmod 777 scripts/test-report.sh
+ ls -ltr scripts/test-report.sh
-rwxrwxrwx 1 jenkins jenkins 238 Dec 9 06:18 scripts/test-report.sh
+ BAZEL_OPTS=--config=ci --config=remote_cache_ci
+ scripts/test-report.sh
/home/jenkins/agent/workspace/team/code-coverage-WIP@tmp/durable-29cd82d6/script.sh: 4: //: Permission denied

脚本是

#!/bin/bash
set -e
which bazel
bazelbin=$(bazel info bazel-bin)
target="//src/cmd/gocoverage"
cmd="${bazelbin}/src/cmd/gocoverage/gocoverage_/gocoverage"
bazel build $target
$cmd -goprefix=go.corp.nvidia.com/maglev ${GOCOVERAGE_OPTS} $@

我必须从脚本中删除#!/bin/bash,然后像下面一样在管道中使用

sh '''
chmod 777 -R scripts
BAZEL_OPTS="--config=ci --config=remote_cache_ci"
bash scripts/test-report.sh
'''.stripIndent()

最新更新