我想自定義環境屬性以編程方式選擇環境進行審批(開發、預生產、生產)。當我嘗試啟動管道時,我看到了這個錯誤。有替代方案嗎?
Job : Environment $(environment) could not be found. The environment does not exist or has not been authorized for use.
variables:
environment: dev
jobs:
- deployment: test
displayName: test
timeoutInMinutes: 0
# creates an environment if it doesn't exist
environment: $(environment)
strategy:
runOnce:
deploy:
steps:
- checkout: self
clean: true
displayName : Checkout repository
- task: NodeTool@0
inputs:
versionSpec: '16.x'
checkLatest: true
uj5u.com熱心網友回復:
對于這個用例,您應該使用引數。這是因為變數在管道的初始決議階段不可用。
parameters:
- name: "environment"
type: string
default: "development"
然后environment: ${{ parameters.environment }}
或者,如果您想變得花哨,可以執行以下操作:
parameters:
- name: "environments"
type: object
default:
- name: development
param1: value
param2: value
- name: test
param1: value
param2: value
# This will look through the environment parameter and create a job for each environment.
- ${{ each environment in parameters.environments }} :
jobs:
- deployment: test
#read in vars from a file in variables/development.yml
variables: variables/${{ environment.name }}.yml
displayName: test
timeoutInMinutes: 0
# creates an environment if it doesn't exist
environment: ${{ environment.name }}
strategy:
runOnce:
deploy:
steps:
- checkout: self
clean: true
displayName : Checkout repository
- task: NodeTool@0
inputs:
versionSpec: '16.x'
checkLatest: true
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/452532.html
標籤:天蓝色 天蓝色的devops 天蓝色管道 yaml
