假设我在管道中具有以下参数:
parameters:
- name: environment
displayName: 'Environment'
default: 'SERVER_0562'
type: string
values:
- 'SERVER_0562'
- 'SERVER_5149'
- 'SERVER_1892'
但是我不希望在运行管道的任何人从下拉列表中选择Environment
时都看到这些名称。然后,我希望看到以下名称:
- QA Server
- DEV Server
- PROD Server
是否有任何“简便”的方法可以做到这一点,或者唯一的方法就是处理条件条件?
${{ if eq(parameters.environment, 'DEV Server') }}:
答案 0 :(得分:1)
请检查以下内容:
parameters:
- name: image
displayName: Pool Image
type: string
default: Ubuntu
values:
- Windows
- Ubuntu
- MacOS
trigger: none
jobs:
- job: build
displayName: build
pool:
${{ if eq(parameters.image, 'Ubuntu') }}:
vmImage: 'ubuntu-latest'
${{ if eq(parameters.image, 'Windows') }}:
vmImage: 'windows-latest'
${{ if eq(parameters.image, 'MacOS') }}:
vmImage: 'macOS-latest'
steps:
- script: echo building $(Build.BuildNumber) with ${{ parameters.image }}
更改问题后,我认为这可能对您有帮助
parameters:
- name: environment
displayName: 'Environment'
default: 'QA Server'
type: string
values:
- 'QA Server'
- 'DEV Server'
- 'PROD Server'
trigger: none
variables:
- name: QA
value: 'SERVER_0562'
- name: DEV
value: 'SERVER_5149'
- name: PROD
value: 'SERVER_1892'
jobs:
- job: build
displayName: build
pool:
vmImage: 'windows-latest'
steps:
- script: echo building $(Build.BuildNumber) with ${{ parameters.environment }}
- powershell: |
If('${{ parameters.environment }}' -eq 'QA Server') {
Write-Host '##vso[task.setvariable variable=folderName;isOutput=true]$(QA)'
} ElseIf('${{ parameters.environment }}' -eq 'DEV Server') {
Write-Host '##vso[task.setvariable variable=folderName;isOutput=true]$(DEV)'
} ElseIf('${{ parameters.environment }}' -eq 'PROD Server') {
Write-Host '##vso[task.setvariable variable=folderName;isOutput=true]$(PROD)'
} Else {
Write-Host 'I am here'
}
name: setFolderName
- powershell: |
Write-Host '$(setFolderName.folderName)'
答案 1 :(得分:1)
受@Krzysztof Madej的贡献启发,我最终通过conditionally assigning variables解决了自己的问题:
let popupShake = {
outFields: ["*"],
"title": function (feature){ <------------- breaks popup, but content below works
let spl = document.createElement("span");
spl.className = "name_plc";
dlv.innerHTML = "<span class='name_plc'></span>";
return spl;
},
"content": function (feature){
let name_plc;
let dlv = document.createElement("div");
dlv.className = "popd";
dlv.innerHTML = `<b><span class='name_plc'></span></b><br>ID: <span class="ida">${feature.graphic.attributes.id}</span><br> URL: <a href="${feature.graphic.attributes.url}" target="_blank">View</a> <br> Updated: ${feature.graphic.attributes.updated} <br>Grid_value: ${feature.graphic.attributes.grid_value}<br> Event Time: ${feature.graphic.attributes.eventTime}`;
setTimeout(() => {
getName();
}, 20);
................
我认为这是一个更容易实现的方法,因为我不依赖于parameters:
- name: environment
displayName: 'Environment'
default: 'QA Server'
type: string
values:
- 'QA Server'
- 'DEV Server'
- 'PROD Server'
trigger: none
variables:
${{ if eq(parameters.environment, 'QA Server') }}:
bacon: SERVER_0562
${{ if eq(parameters.environment, 'DEV Server') }}:
bacon: SERVER_5149
${{ if eq(parameters.environment, 'PROD Server') }}:
bacon: SERVER_1892
jobs:
- job: build
displayName: build
steps:
- script: echo building $(Build.BuildNumber) with ${{ variables.bacon }}
脚本。