My question is specific but I guess simple who knows PowerShell more than I.
Let me explain my question :
I need 6 different webjobs under 1 web service. my webjob will be the SonicMQ listener we developed can only listens to a single queue.
My locations [istanbul,berlin, hamburg.....]
I am trying to create 6 different webjobs with "-istanbul","-berlin","-hamburg" . . . suffix by using for loop in a task via Powershell.
below task should work like that : (psode code)
var listoflocations = [istanbul,berlin.hamburg, . . ]
foreach location in listoflocations
powershell -create mywebjob-location
my yaml file (small part): how can I use powershell below ?
For this purpose I spend my time with some changes Thanks to your advice. When I run below yaml I am getting this error:
- stage: Deploy_Test
displayName: 'Deploy test'
dependsOn: Test
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
pool:
name: 'bmersgtsteuw-app-eurotracs-pool'
jobs:
- deployment: yyyOrderShipmentJob
displayName: 'Deploy Order Shipment Job'
environment: 'xxx-CF-Test'
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: drop
- task: "HOW CAN I USE POWERSHELL HERE WITH FOREACH LOOP ? [istanbul,berlin.hamburg, . . ]"
inputs:
ConnectionType: AzureRM
azureSubscription: 'ARM-Con-xxx-yyy-TST-EUW-APP'
appType: 'webApp'
WebAppName: 'bmeapptsteuw-app-eurotracs'
package: '$(Pipeline.Workspace)/drop/xxx.yyy.OrderShipmentJob-$(Build.BuildNumber).zip'
removeAdditionalFilesFlag: true
My FINAL pipeline yaml :
trigger:
- main
pool:
vmImage: ubuntu-latest
parameters:
- name: locations
type: object
default: [Berlin,Hamburg,Südwestfalen,Weser-Ems,Ostfalen,Westfalen]
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- ${{ each location in parameters.locations }}:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'Write-Host ${{ location }}'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/MyWebJob.csproj'
arguments: '--configuration $(buildConfiguration) --output $(build.artifactStagingDirectory)\App_Data\jobs\continuous\MyWebJob-${{ location }}'
zipAfterPublish: false
modifyOutputPath: false
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
MY DESIRE RESULT :