I am working in Azure DevOps CICD pipeline. I have created an agent in Default Pool which is a Self-Hosted Agent.
My Agent Details:
Agent.Name: Deployment-Agent Agent.Version: 2.210.1
Below is my yaml file:
trigger: none
variables:
- name: solution
value: 'MyApp.sln'
- name: buildPlatform
value: 'Any CPU'
- name: buildConfiguration
value: 'Release'
- name: "npm_config_cache"
value: $(Pipeline.Workspace)/.npm
stages:
- stage: StartAzVMAgent
jobs:
- job: MsHostedAgentJobStartAzVM
timeoutInMinutes: 0
pool:
vmImage: 'windows-latest'
steps:
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: "Az-DevOps-AgentManager"
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az --version
az account show
az vm start --name MyDeployment-Agent --no-wait --resource-group MyDeployment
- stage: __default
jobs:
- job: Job
timeoutInMinutes: 0
pool:
name: Default
demands:
- Agent.Name -equals Deployment-Agent
steps:
- task: Npm@1
displayName: Install Node dependencies (packages)
inputs:
command: custom
customCommand: install --save --legacy-peer-deps
workingDir: 'MyApp.WebUI\MyClientApp'
- task: Npm@1
displayName: Install Node dependencies (packages)
inputs:
command: custom
customCommand: install sweetalert2 file-saver
workingDir: 'MyApp.WebUI\MyClientApp'
- task: Cache@2
displayName: Cache npm
inputs:
key: 'npm | "$(Agent.OS)" | **/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(npm_config_cache)
- script: npm ci
- task: CmdLine@2
displayName: Building Client App
inputs:
script: node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --configuration production --aot --build-optimizer=true --common-chunk=true --named-chunks=false --optimization=true --vendor-chunk=true --progress=true
workingDirectory: 'MyApp.WebUI\MyClientApp'
- task: CopyFiles@2
displayName: 'Copy Client Project'
inputs:
Contents: |
MyApp.WebUI\MyClientApp\dist\**
TargetFolder: '$(build.artifactstagingdirectory)/client'
flattenFolders: false
CleanTargetFolder: true
- task: UseDotNet@2
displayName: Use .NET 6.0
inputs:
packageType: 'sdk'
version: '6.0.x'
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: true
zipAfterPublish: true
arguments: '--output $(build.artifactstagingdirectory)/api'
- task: CmdLine@2
displayName: Create EF Scripts
inputs:
script: |
dotnet ef migrations add FreshDb_08022021 -c MyAppDbcontext
dotnet ef migrations script --idempotent --output migrations.sql --project MyApp.Persistence/MyApp.Persistence.csproj --context MyAppDbContext
- task: CopyFiles@2
displayName: 'Copy EF Scripts to Staging'
inputs:
Contents: "**\\migrations.sql \n"
TargetFolder: '$(build.artifactstagingdirectory)'
flattenFolders: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: StoptAzVMAgent
dependsOn: __default
condition: always()
jobs:
- job: MsHostedAgentJobStopAZVm
timeoutInMinutes: 0
pool:
vmImage: 'windows-latest'
steps:
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: "Az-DevOps-AgentManager"
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az --version
az account show
az vm deallocate --name MyDeployment-Agent --no-wait --resource-group MyDeployment
However i am getting the below error even when my agent is enabled and running.
#Error: No agent found in pool Default which satisfies the specified demands: Use_for -equals Deployment-Agent, npm, Agent.Version -gtVersion 2.182.1
Can I know from were does it takes this 2.182.1 as version as my agent version is higher than this but still it takes previous version and gives me error? Can anyone please help me on this as I am new to azure cicd?
According to the error message, please try the following steps:
For more information, you could refer to:https://learn.microsoft.com/en-us/azure/devops/pipelines/process/demands?view=azure-devops&tabs=yaml
And install the NPM:https://docs.npmjs.com/downloading-and-installing-node-js-and-npm