我正在使用 bash 組裝 YAML 構建管道,如下所示。
cat <<EOT >> ${BUILD_SOURCESDIRECTORY}/azure-pipelines.yml
- template: templates/deploy-to-env-ssh.yml@infrastructure
parameters:
dockerHostEndpoint: ${DOCKER_HOST}
jobName: ${BASENAME}
stackName: ${STACK_NAME}
composeFile: ${STACK_NAME}.yml
schedule: ???
$(cat schedule.yml)
tz: ${TZ}
EOT
我想要的是將以下 YAML 存盤schedule為一個字串,我可以在管道的另一部分重用它。
version: 1.4
jobs:
DockerJob:
cmd: docker ps
time: "*"
notifyOnSuccess:
- type: stdout
data:
- stdout
但它似乎需要縮進。
uj5u.com熱心網友回復:
您可以使用該pr實用程式:
cat <<EOF >> ${BUILD_SOURCESDIRECTORY}/azure-pipelines.yml
- template: templates/deploy-to-env-ssh.yml@infrastructure
parameters:
dockerHostEndpoint: ${DOCKER_HOST}
jobName: ${BASENAME}
stackName: ${STACK_NAME}
composeFile: ${STACK_NAME}.yml
schedule: $(printf "\n" && pr -to 8 schedule.yml)
tz: ${TZ}
EOT
我之所以使用printf "\n",是因為$(…)如果您想$(…)在新行上寫入,則需要將其放在第一列,因為包括第一行在內的每一行都將被給定數量的空格偏移。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/439460.html
下一篇:替換檔案名bash中的部分字串
