我在外壳脚本声明性管道中使用以下if语句:
def currTaskDef = sh (
returnStdout: true,
script: """
#!/bin/bash
RESULT=`(aws ecs describe-task-definition --task-definition ${env.TASK_FAMILY} | egrep 'revision' | tr ',' ' ' | awk '{print \$2}') 2> /dev/null`
if ( ! "\$RESULT" ) then
echo 1
else
aws ecs describe-task-definition --task-definition ${env.TASK_FAMILY} \
| egrep 'revision' \
| tr ',' ' ' \
| awk '{print \$2}'
fi
"""
).trim()
我正在关注以下权限被拒绝
:/home/jenkins/workspace/dev-test-local@tmp/durable-28ccc40c/script.sh: 4: /home/jenkins/workspace/dev-test-local@tmp/durable-28ccc40c/script.sh: : Permission denied
...
Finished: SUCCESS
如果我使用bash if语句if不起作用:
if [[ ! "\$RESULT" ]]; then
echo 1
else
aws ecs describe-task-definition --task-definition ${env.TASK_FAMILY} \
| egrep 'revision' \
| tr ',' ' ' \
| awk '{print \$2}' \
fi
输出:
+ [[ ! ]]
/home/jenkins/workspace/dev-test-local@tmp/durable-d7af8721/script.sh: 4: /home/jenkins/workspace/dev-test-local@tmp/durable-d7af8721/script.sh: [[: not found
如何摆脱被拒绝的权限以及为什么bash if语句不起作用?