“如何修复 BASH 中的'语法错误接近'错误”



我正在为运行删除作业设置一个新条件(如果存在但在生产情况下不起作用(。

GNU bash, v4.3.48(1(-release (x86_64-pc-linux-gnu(

docker run -e GO_DEPENDENCY_LABEL_PIPE='XXXXX' -e CREDENTIAL_NAME='production.XXXXX' -e KUBE_TOKEN='XXXXX' -v /go/pipelines/deploy-portal-site-data/helm:/helm --add-host=api.production.XXXXX:00.000.000.000 --rm -t --entrypoint /bin/bash docker.XXXXX.com.br/kubectl-prod:latest --login -c "kubectl config set-credentials production.XXXXX --token=XXXXX; VerifyJob=0; [[  -ge 1 ]] && kubectl -n production delete job portal-site-data-production || echo 'There is no job at the moment'"

我期望干净作业的输出,但实际输出是

Creating /root/.helm/repository 
Creating /root/.helm/repository/cache 
Creating /root/.helm/repository/local 
Creating /root/.helm/starters 
Creating /root/.helm/cache/archive 
Creating /root/.helm/repository/repositories.yaml 
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com 
Adding local repo with URL: http://127.0.0.1:8879/charts 
$HELM_HOME has been configured at /root/.helm.
Not installing Tiller due to 'client-only' flag having been set
Happy Helming!
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈ 
"gfn-helm-repo" has been added to your repositories
/bin/bash: -c: line 0: conditional binary operator expected
/bin/bash: -c: line 0: syntax error near `1'
/bin/bash: -c: line 0: `kubectl config set-credentials production.XXXXX --token=XXXXX; VerifyJob=0; [[  -ge 1 ]] && kubectl -n production delete job portal-site-data-production || echo 'There is no job at the moment''
[[  -ge 1 ]]

我认为错误来自命令的这一部分。

它正在测试"未定义"是否大于或等于 1

我删除了我的图表 helm delete portal-site-data-production --tiller-namespace production --purge

并将 \ 放在">

set -x
docker pull $DOCKER_HELM_PROD_IMAGE
docker run 
-e GO_DEPENDENCY_LABEL_PIPE='${GO_DEPENDENCY_LABEL_PIPE}' 
-e CREDENTIAL_NAME='${CREDENTIAL_NAME}' 
-e KUBE_TOKEN='${KUBE_TOKEN}' 
-v $PWD/helm:/helm 
--add-host=api.production.XXXXX:00.000.000.000 
--rm -t --entrypoint /bin/bash 
$DOCKER_HELM_PROD_IMAGE 
--login -c "kubectl config set-credentials ${CREDENTIAL_NAME} --token=${KUBE_TOKEN}; VerifyJob=$(kubectl -n production get job| grep -c portal-site-data-production); "[[ ${VerifyJob} -ge 1 ]]" && kubectl -n production delete job portal-site-data-production || echo "There is no job at the moment""

现在好了,非常感谢大家。

最新更新