Azure Devops-Powershell에서 변수를 설정할 수 없음

Ciaran O'Neill

Azure Devops 릴리스 파이프 라인 (yaml이 아닌 클래식 편집기 사용)이 있고 인라인 powershell 스크립트에서 변수를 설정하는 데 문제가 있습니다. 스크립트의 관련 부분은 다음과 같습니다.

Write-Host "Web is $web"
Write-Host "App is $app"

Write-Host "##vso[task.setvariable variable=MyWebEnv;]$web"
Write-Host "Set Web to $($MyWebEnv)"

Write-Host "##vso[task.setvariable variable=MyAppEnv;]$app"
Write-Host "Set App to $(MyAppEnv)" 

로그 파일은 내 $ web 및 $ app 변수가 올바른 값을 보유하고 있지만 설정이 작동하지 않음을 나타냅니다.

$ ($ env : MyWebEnv) 및 $ (MyWebEnv) 형식으로 값을 작성하려고 시도했으며 두 형식 모두 ADO 변수가 올바르게 설정되지 않았 음을 나타냅니다.

내 변수는 파이프 라인의 변수 탭에서 정의됩니다. 대기열 시간에 설정 가능으로 설정됩니다. 정의에 값을 설정하지 않고 초기 값을 시도했는데 초기 값을 덮어 쓰지 않는 것을 알 수 있습니다.

자체 호스팅 에이전트와 Azure Pipelines Hosted 에이전트 모두에서 실행 해 보았습니다. 동일한 결과입니다. 문제없이 비슷한 작업을 수행하는 또 다른 릴리스 파이프 라인이 있습니다.

후속 단계에서 변수를 사용하려고합니다.

스테이지가 실행되는지 여부를 제어하기 위해 변수를 사용하고 싶기 때문에 변수를 파일이나 다른 것에 쓰고 싶지 않습니다.

편집 : Levi의 의견에 따라 isOutput = true를 추가하고 동일한 단계의 후속 단계에서 변수를 검사하려고 시도했습니다. 후속 단계에서도 표시되지 않습니다.

파이프 라인 출력

========================================================================= Edit 2: I must have had a non visible character somewhere. I was composing the powershell in an external editor (just so I had more space) and pasting into the inline textbox in ADO - when I typed in the exact same thing I had into the editor it started working - sort of.

I can set the variable now and it's appearing in the task below, but what I really want is to use it in the next stages - in the IIS deployment group to control that IIS server A runs, but IIS server B doesn't. I'm attempting to do this in the Additional Options Run Expression.

I've tried and(succeeded(), eq(variables['MyWebEnv'], 'myvalue')

or (where MyOutput. is the name given to my output reference when setting the variable) and(succeeded(), eq(variables['MyOutpub.MyWebEnv'], 'myvalue') or and(succeeded(), eq(variables['MyOutpub_MyWebEnv'], 'myvalue')

To clarify, I'm doing this on the IIS Deployment Group itself, and not on any of the tasks within that group.

I keep seeing that the deployment is skipped due to: Evaluating: eq(variables['MyOutput,MyWebEnv'], 'myvalue') Expanded: eq(Null, 'myvalue') Result: False

Krzysztof Madej

As Levi Lu mentioned you can access pipeline variables in the next step. So if you set variables like this here:

여기에 이미지 설명 입력

$web ="some-web"
$app ="some-app"

Write-Host "##vso[task.setvariable variable=MyWebEnv;]$web"
Write-Host "##vso[task.setvariable variable=MyAppEnv;]$app"

then you can read them in this way:

여기에 이미지 설명 입력

Write-Host "Set Web to $(MyWebEnv)"
Write-Host "Set App to $(MyAppEnv)" 

여기에 이미지 설명 입력

And if you want to access them via env variables you should use this syntax:

Write-Host "Set Web to $($env:MYWEBENV)"
Write-Host "Set App to $($env:MYAPPENV)" 

Answer for EDIT 2:

What you actually need is output cross stage variables which is supported in YAML but not in classic pipelines. Please check this topics. You can overcome this but it requires an extra effort as it shown here. However, please remember that you can't publish an artifact from release pipeline.

여기 에 크로스 스테이지 변수에 대한 문서가 있지만 위와 같이 YAML에서 작동합니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Devops 단계에서 powershell 출력 변수를 설정할 수 없습니다.

분류에서Dev

DevOps Release Pipeline 내에서 Azure CLI를 사용하여 변수를 설정할 수 없습니다.

분류에서Dev

사용자가 Azure DevOps의 스프린트에서 작업 보드 설정을 구성 할 수 없음

분류에서Dev

Azure DevOps에서 Dotnet 3.0.100 앱을 Octopus로 푸시 할 수 없음

분류에서Dev

Powershell의 Azure DevOps Rest API에서 일치하는 매개 변수가 없음

분류에서Dev

Azure DevOps CD에 DacPac을 배포 할 수 없음

분류에서Dev

JavaScript에서 변수를 설정할 수 없음 – FancyInput 예제

분류에서Dev

PowerShell에서 실행 정책을 설정할 수 없음

분류에서Dev

스크립트에서 동적으로 Azure DevOps 변수 설정

분류에서Dev

Azure DevOps의 PowerShell 작업에서 파이프 라인 변수를 사용할 수 있나요?

분류에서Dev

Bash 스크립트의 cURL 명령에서 PAT를 사용하여 Azure DevOps API에 액세스 할 수 없음

분류에서Dev

Azure DevOps. 새 호스팅 에이전트 풀을 생성 할 수 없음

분류에서Dev

Azure DevOps에서 사용자 설정을 확장 할 수 있습니까?

분류에서Dev

Azure Devops 파이프 라인에서 al.exe를 찾을 수 없음

분류에서Dev

Mule ESB에서 값을 변수로 설정할 수 없음

분류에서Dev

Azure DevOps "Visual Studio 테스트"- "재정의 매개 변수"를 사용할 때 "실패한 테스트 다시 실행"을 활성화 할 수 없음

분류에서Dev

Azure devops를 사용하여 Ionic iOS 앱을 빌드 할 수 없음

분류에서Dev

Azure ML에 R 라이브러리를 설치할 수 없음

분류에서Dev

클라우드를 설정 한 후 Jenkins에서 Azure VM을 프로비저닝 할 수 없음

분류에서Dev

~ / .profile에서 환경 변수를 설정할 수 없습니다.

분류에서Dev

Bash에서 변수를 설정할 수 없습니다.

분류에서Dev

Kaspersky Endpoint Security를 설치 한 후 Azure VM에서 RDP를 사용할 수 없음

분류에서Dev

Azure devops Nuget에 게시 할 수 없습니다.

분류에서Dev

Mac 에이전트의 Azure devops 파이프 라인 : 번들 설치시 Gemfile을 찾을 수 없음

분류에서Dev

DevOps에서 Azure Analysis Services 데이터베이스 역할 수정

분류에서Dev

ODBC를 사용하여 MySQL에서 Excel로 사용자 정의 변수를 설정할 수 없음

분류에서Dev

Powershell에서 Azure 함수 설정

분류에서Dev

VS2015에서 Azure.Storage.Blobs.12.5.1 패키지를 설치할 수 없음

분류에서Dev

Json 요청에서 flowVars를 키로 설정할 수 없음

Related 관련 기사

  1. 1

    Devops 단계에서 powershell 출력 변수를 설정할 수 없습니다.

  2. 2

    DevOps Release Pipeline 내에서 Azure CLI를 사용하여 변수를 설정할 수 없습니다.

  3. 3

    사용자가 Azure DevOps의 스프린트에서 작업 보드 설정을 구성 할 수 없음

  4. 4

    Azure DevOps에서 Dotnet 3.0.100 앱을 Octopus로 푸시 할 수 없음

  5. 5

    Powershell의 Azure DevOps Rest API에서 일치하는 매개 변수가 없음

  6. 6

    Azure DevOps CD에 DacPac을 배포 할 수 없음

  7. 7

    JavaScript에서 변수를 설정할 수 없음 – FancyInput 예제

  8. 8

    PowerShell에서 실행 정책을 설정할 수 없음

  9. 9

    스크립트에서 동적으로 Azure DevOps 변수 설정

  10. 10

    Azure DevOps의 PowerShell 작업에서 파이프 라인 변수를 사용할 수 있나요?

  11. 11

    Bash 스크립트의 cURL 명령에서 PAT를 사용하여 Azure DevOps API에 액세스 할 수 없음

  12. 12

    Azure DevOps. 새 호스팅 에이전트 풀을 생성 할 수 없음

  13. 13

    Azure DevOps에서 사용자 설정을 확장 할 수 있습니까?

  14. 14

    Azure Devops 파이프 라인에서 al.exe를 찾을 수 없음

  15. 15

    Mule ESB에서 값을 변수로 설정할 수 없음

  16. 16

    Azure DevOps "Visual Studio 테스트"- "재정의 매개 변수"를 사용할 때 "실패한 테스트 다시 실행"을 활성화 할 수 없음

  17. 17

    Azure devops를 사용하여 Ionic iOS 앱을 빌드 할 수 없음

  18. 18

    Azure ML에 R 라이브러리를 설치할 수 없음

  19. 19

    클라우드를 설정 한 후 Jenkins에서 Azure VM을 프로비저닝 할 수 없음

  20. 20

    ~ / .profile에서 환경 변수를 설정할 수 없습니다.

  21. 21

    Bash에서 변수를 설정할 수 없습니다.

  22. 22

    Kaspersky Endpoint Security를 설치 한 후 Azure VM에서 RDP를 사용할 수 없음

  23. 23

    Azure devops Nuget에 게시 할 수 없습니다.

  24. 24

    Mac 에이전트의 Azure devops 파이프 라인 : 번들 설치시 Gemfile을 찾을 수 없음

  25. 25

    DevOps에서 Azure Analysis Services 데이터베이스 역할 수정

  26. 26

    ODBC를 사용하여 MySQL에서 Excel로 사용자 정의 변수를 설정할 수 없음

  27. 27

    Powershell에서 Azure 함수 설정

  28. 28

    VS2015에서 Azure.Storage.Blobs.12.5.1 패키지를 설치할 수 없음

  29. 29

    Json 요청에서 flowVars를 키로 설정할 수 없음

뜨겁다태그

보관