0

次の 2 つの CLI コマンドにランタイム変数を渡すと、パイプラインで次の問題が発生し続けます。

az webapp create --resource-group $(RG) --plan $(azureSubscription) --name "%APPNAME%"'

az webapp config appsettings set --name "%APPNAME%"' --resource-group $(RG) --settings '/home/vsts/work/1/s/studentsettings.json' --subscription $(azureSubscription)

これはエラーです:

/home/vsts/work/_temp/azureclitaskscript1617264397722.sh: line 1: syntax error near unexpected token `('

私が作成したコードのスニペットを添付しました。誰か助けてください。これを修正するのに 8 時間、夜遅くまで費やしました。これが機能する必要があります...

- job: job2
  displayName: 'Get Variable Value for Student Env'
  dependsOn: job1
  steps:
  - task: AzureCLI@1
    displayName: 'Azure CLI '
    inputs:
      azureSubscription: $(azureSubscription)
      scriptLocation: inlineScript
      inlineScript: |
        mkdir $(Pipeline.Workspace)\BlobFile
        az storage blob download --container-name $(containername) --file '$(Pipeline.Workspace)/s/student.json' --name 'student.json' --connection-string 'MY VALUE'
        az storage blob download --container-name 'private' --file '$(Pipeline.Workspace)/s/studentsettings.json' --name 'studentappsettings.json' --connection-string 'MY VALUE'
  - pwsh: |
      cd '/home/vsts/work/1/s/'
      ls
      $armOutput = Get-Content '/home/vsts/work/1/s/student.json' | convertfrom-json
      $student = $armOutput.studentvalue #use student not studentvalue
      $type = $armOutput.type
      $appservice = $armOutput.appservicevalue
      Write-Host "The value of [$student] is [$appservice]"
      Write-Host "##vso[task.setvariable variable=studentvalue;isOutput=true]$student" #use studentvalue not $studentvalue
      Write-Host "##vso[task.setvariable variable=appservicevalue;isOutput=true]$appservice" #use appservicevalue not $appservice
    name: setvarStep

  - script: echo $(setvarStep.studentvalue)
  - script: echo $(setvarStep.appservicevalue)
    name: echovar
  
- job: job3
  displayName: Create Web App 
  dependsOn: job2
  variables:
    webappname: $[ dependencies.job2.outputs['setvarStep.studentvalue'] ]
    appservicename: $[ dependencies.job2.outputs['setvarStep.appservicevalue'] ]
  steps:
  - script: export APPNAME=webappname  
  - script: echo %APPNAME%
  - script: export APPPLAN=appservicename
  - script: echo %APPPLAN%

# Create Web App
  - task: AzureCLI@1
    displayName: 'Create Web App in $(appservicename)'
    inputs:
      azureSubscription: $(azureSubscription)
      scriptLocation: inlineScript
      inlineScript: |
        az webapp create --resource-group $(RG) --plan $(azureSubscription) --name "%APPNAME%"'

 # Download Artifact File
  - download: none
  - task: DownloadPipelineArtifact@2
    displayName: 'Download Build Artifacts'
    inputs:
      patterns: '**/*.zip'
      path: '$(Build.ArtifactStagingDirectory)'

  # deploy to Azure Web App 
  - task: AzureWebApp@1
    displayName: 'Azure Web App Deploy: $(webappname)'
    inputs:
      package: $(Build.ArtifactStagingDirectory)/**/*.zip 
      azureSubscription: $(appconnectionname)
      ConnectedServiceName: $(appconnectionname)
      appName: '$(webappname)'
      ResourceGroupName: $(RG)  

  # Change App Settings
  - task: AzureCLI@1
    displayName: 'Change WebApp Settings'
    inputs: 
     azureSubscription: $(azureSubscription)
     scriptLocation: inlineScript
     inlineScript: |
       az webapp config appsettings set --name "%APPNAME%"' --resource-group $(RG) --settings '/home/vsts/work/1/s/studentsettings.json' --subscription $(azureSubscription)

4

1 に答える 1