在Azure DevOps中使用新的部署作业.找不到文物 [英] Use new Deployment Job in Azure DevOps. Can't find artifacts
问题描述
我需要使用Azure Devops将Asp.Net核心应用程序部署到Azure WebApp.
I need to deploy an Asp.Net Core Application to Azure WebApp using Azure Devops.
我有以下有效的Azure-Pipelines YAML文件:
I have the following working Azure-Pipelines YAML file:
trigger:
- master
variables:
buildConfiguration: 'Release'
buildPlatform: 'any cpu'
version: '0.2.0'
stages:
- stage: 'Stage1'
jobs:
# Previous Jobs like Build, Test, ...
- job: 'Publish'
pool:
vmImage: 'Ubuntu-16.04'
dependsOn: 'Test'
steps:
- task: DotNetCoreCLI@2
displayName: 'Publish'
inputs:
command: publish
publishWebProjects: false
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
zipAfterPublish: true
- task: PublishBuildArtifacts@1
displayName: 'Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy'
inputs:
package: '$(build.artifactstagingdirectory)/App.Api.zip'
azureSubscription: 'MyName.Azure'
appType: 'Web App On Windows'
webAppName: 'myname-api'
This works fine but I would like to use the new Deployment Job.
我删除了部署"任务,并在发布"任务之后将其添加为新的部署任务:
I removed the 'Deploy' task and added it as a new Deployment Job after the 'Publish' job:
- deployment: DeployJob
dependsOn: 'Publish'
pool:
vmImage: Ubuntu-16.04
environment: production
strategy:
runOnce:
deploy:
steps:
- task: AzureRmWebAppDeployment@4
inputs:
package: '$(build.artifactstagingdirectory)/App.Api.zip'
azureSubscription: 'MyName.Azure'
appType: 'Web App On Windows'
webAppName: 'myname-api'
您会看到"AzureRmWebAppDeployment @ 4"与以前相同.
You can see that the 'AzureRmWebAppDeployment@4' is the same as before.
但是现在在运行管道时出现以下错误:
But now I get the following error when I run the pipeline:
Download artifact to: /home/vsts/work/1/
Could not find any pipeline artifacts in the build.
我想念什么?如何解决这个问题?
What am I missing? How to fix this?
推荐答案
我自己整天都在为此苦苦挣扎,直到跌入解决方案为止.似乎有一些捆绑到作业中的默认帮助程序"任务,而部署作业具有添加的默认下载任务.我仍然不确定在我的情况下它试图下载什么,但是它导致了您描述的相同问题.
I've struggled with this all day myself, until stumbling into a solution. It seems there are a few default "helper" tasks that get bundled into the jobs, and the deployment jobs have a default download task that gets added. I'm still not sure what it was trying to download in my case, but it was causing the same problem you describe.
尝试将- download: none
任务添加到部署作业的步骤中,并改为显式指定任务.这样的事情应该起作用:
Try adding a - download: none
task to your deployment job's steps, and specifying the tasks explicitly instead. Something like this should work:
- stage: deploy_dev
displayName: Development environment
jobs:
- deployment: Deploy
displayName: Deploy to Development environment
environment: myproject-dev
pool:
vmImage: ubuntu-16.04
strategy:
runOnce:
deploy:
steps:
- download: none
- task: DownloadBuildArtifacts@0
inputs:
artifactName: $(ArtifactName)
buildType: 'current'
downloadType: 'single'
downloadPath: '$(System.ArtifactsDirectory)'
Documentation for the download shortcut can be found here: https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#download
希望有帮助!
这篇关于在Azure DevOps中使用新的部署作业.找不到文物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!