我使用MsBuild在Azure DevOps中创建了一个CI管道来发布工件。构建管道工作正常,并发布了一个名为“website”的工件(将工件下载为.zip)
variables:
# MsBuild@1 Variables
buildSolution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: ${{ parameters.buildConfiguration }}
msbuildArgs: '/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:ExcludeGeneratedDebugSymbol=true /p:WarningLevel=0 /p:publishUrl=$(build.artifactStagingDirectory)\website /p:configuration=$(buildConfiguration)'
buildArtifactName: website # PublishPipelineArtifactName
# Pipeline Start
stages:
- stage: BuildPublishArtifact
jobs:
- job:
workspace:
clean: ${{ variables.workspaceClean }}
displayName: 'Build solution'
# Display Branch Name
steps:
- task: PowerShell@2
displayName: 'Display Branch, Commit and Build Configuration'
inputs:
targetType: 'inline'
script: |
echo "Bulding Artifact named $(buildArtifactName) for Branch $(Build.SourceBranch) and Commit $(Build.SourceVersion) in Build Configuration $(buildConfiguration)"
# Restore NuGet packages
- task: NuGetCommand@2
displayName: "Restore NuGet"
inputs:
command: 'restore'
restoreSolution: '$(buildSolution)'
feedsToUse: 'config'
nugetConfigPath: '$(buildNuGet)'
# Build Artifact using MSBuild@1 task
- task: MSBuild@1
inputs:
solution: '$(buildSolution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArguments: '$(msbuildArgs)'
clean: true
createLogFile: true
logFileVerbosity: 'detailed'
# List Files
- task: PowerShell@2
displayName: 'Diagnostics - List Files'
inputs:
targetType: 'inline'
script: $(dir)
# List Files
- task: PowerShell@2
displayName: 'Diagnostics - List Build Artifact'
inputs:
targetType: 'inline'
script: $(dirArtifact)
#- stage: Run Tests
# jobs:
# - job: RunAutomatedTests
# displayName: 'Run Automated Tests'
# steps:
# - task: VSTest@2
# displayName: 'Run automated tests'
# inputs:
# testAssemblyVer2: |
# **\*test*.dll
# !**\*TestAdapter.dll
# !**\obj\**
# searchFolder: '$(System.DefaultWorkingDirectory)'
# platform: '$(buildPlatform)'
# configuration: '$(BuildConfiguration)'
# Publish Pipeline Artifact
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(build.artifactStagingDirectory)/website'
artifact: 'website'
publishLocation: 'pipeline'
尝试通过CD Pipeline部署到Azure Web Apps,尽管我总是以msg 'No package found with specified pattern:D:\a\1\website
'我不知道在AzureRmWebAppDeployment@4中要避开此消息并成功部署,必须瞄准哪个目录?
package: 'D:\a\1\website'
package: '$(Pipeline.Workspace)/website'
CD管道无法判断我是否真的需要“ExtractFiles@1”
stages:
- stage: DownloadArtifactAndDeploy
displayName: 'Deploy Artifact to Environments'
jobs:
- job: DownloadArtifact
displayName: 'Download Pipeline Artifact'
pool:
vmImage: $(vmImage)
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'specific'
project: '9035b146-1805-424b-913a-1e3ff3ec5b96'
definition: '5593'
buildVersionToDownload: 'latest'
targetPath: '$(Pipeline.Workspace)'
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Pipeline.Workspace)/*.zip'
destinationFolder: '$(Pipeline.Workspace)/website'
cleanDestinationFolder: true
overwriteExistingFiles: false
- ${{ if eq(parameters.deployToNonProd, true) }}:
- job: DeployNonProd
displayName: 'Deploy Artifact to NonProd'
dependsOn: DownloadArtifact
pool:
vmImage: $(vmImage)
steps:
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'HAWeb2-CFS-NonProd'
appType: 'webApp'
WebAppName: 'rg-haweb-cfs-dev-cms-single'
package: 'D:\a\1\website'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
RuntimeStack: 'ASP.NET|4.7'
TakeAppOfflineFlag: true
ExcludeFilesFromAppDataFlag: true
RenameFilesFlag: true
- ${{ if eq(parameters.deployToQA, true) }}:
- job: DeployQA
displayName: 'Deploy Artifact to QA'
dependsOn: DownloadArtifact
pool:
vmImage: $(vmImage)
steps:
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'HAWeb2-CFS-QA'
appType: 'webApp'
WebAppName: 'rg-haweb-cfs-qa-cms-single'
package: '$(Pipeline.Workspace)/website'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
RuntimeStack: 'ASP.NET|4.7'
TakeAppOfflineFlag: true
ExcludeFilesFromAppDataFlag: true
RenameFilesFlag: true
- ${{ if eq(parameters.deployToProd, true) }}:
- job: DeployProd
displayName: 'Deploy Artifact to Prod'
dependsOn: DownloadArtifact
pool:
vmImage: $(vmImage)
steps:
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'HAWeb2-CFS-Prod'
appType: 'webApp'
WebAppName: 'rg-haweb-cfs-prod-cms-single'
package: '$(Pipeline.Workspace)/website'
enableCustomDeployment: true
DeploymentType: 'webDeploy'
RuntimeStack: 'ASP.NET|4.7'
TakeAppOfflineFlag: true
ExcludeFilesFromAppDataFlag: true
RenameFilesFlag: true
来自AzureRmWebAppDeployment的日志消息
##[debug]loading ENDPOINT_AUTH_SCHEME_ac049b99-4397-487c-ba76-490f2fff88ae
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading INPUT_ADDITIONALARGUMENTS
##[debug]loading INPUT_CONNECTEDSERVICENAME
##[debug]loading INPUT_CONNECTIONTYPE
##[debug]loading INPUT_DEPLOYMENTTYPE
##[debug]loading INPUT_DEPLOYTOSLOTORASEFLAG
##[debug]loading INPUT_EXCLUDEFILESFROMAPPDATAFLAG
##[debug]loading INPUT_INLINESCRIPT
##[debug]loading INPUT_PACKAGE
##[debug]loading INPUT_PUBLISHPROFILEPATH
##[debug]loading INPUT_REMOVEADDITIONALFILESFLAG
##[debug]loading INPUT_RENAMEFILESFLAG
##[debug]loading INPUT_RUNTIMESTACK
##[debug]loading INPUT_SCRIPTPATH
##[debug]loading INPUT_SETPARAMETERSFILE
##[debug]loading INPUT_SLOTNAME
##[debug]loading INPUT_TAKEAPPOFFLINEFLAG
##[debug]loading INPUT_USEWEBDEPLOY
##[debug]loading INPUT_WEBAPPKIND
##[debug]loading INPUT_WEBAPPNAME
##[debug]loading INPUT_XMLTRANSFORMATION
##[debug]loading INPUT_XMLVARIABLESUBSTITUTION
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 31
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]agent.proxyurl=undefined
##[debug]VSTS_ARM_REST_IGNORE_SSL_ERRORS=undefined
##[debug]AZURE_HTTP_USER_AGENT=VSTS_ccbf3a83-7845-4e2d-9520-e48169652e72_build_5910_0
##[debug]check path : D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]adding resource file: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]system.culture=en-US
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]Agent.TempDirectory=D:\a\_temp
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]Resource file has already set to: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\module.json
##[debug]check path : D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\task.json
##[debug]adding resource file: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\task.json
##[debug]system.culture=en-US
##[debug]check path : D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-webdeployment-common\module.json
##[debug]adding resource file: D:\a\_tasks\AzureRmWebAppDeployment_497d490f-eea7-4f2b-ab94-48d9c1acdcb1\4.223.2\node_modules\azure-pipelines-tasks-webdeployment-common\module.json
##[debug]system.culture=en-US
##[debug]ConnectionType=AzureRM
##[debug]WebAppKind=webApp
##[debug]DeployToSlotOrASEFlag=false
##[debug]GenerateWebConfig=undefined
##[debug]WebConfigParameters=undefined
##[debug]XmlTransformation=false
##[debug]JSONFiles=undefined
##[debug]XmlVariableSubstitution=false
##[debug]TakeAppOfflineFlag=true
##[debug]RenameFilesFlag=true
##[debug]AdditionalArguments=-retryAttempts:6 -retryInterval:10000
##[debug]ScriptType=undefined
##[debug]InlineScript=:: You can provide your deployment commands here. One command per line.
##[debug]ScriptPath=D:\a\1\s
##[debug]DockerNamespace=undefined
##[debug]AppSettings=undefined
##[debug]StartupCommand=undefined
##[debug]ConfigurationSettings=undefined
##[debug]ConnectedServiceName=ac049b99-4397-487c-ba76-490f2fff88ae
##[debug]WebAppName=rg-haweb-cfs-qa-cms-single
##[debug]Processed: ##vso[telemetry.publish area=TaskEndpointId;feature=AzureRmWebAppDeployment]{"endpointId":"ac049b99-4397-487c-ba76-490f2fff88ae"}
##[debug]Package=D:\a\1\website
##[debug]Finding files matching input: D:\a\1\website
##[debug]No matching files were found with search pattern: D:\a\1\website
##[debug]Deployment Failed with Error: Error: No package found with specified pattern: D:\a\1\website<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
##[debug]task result: Failed
##[error]Error: No package found with specified pattern: D:\a\1\website<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
##[debug]Processed: ##vso[task.issue type=error;]Error: No package found with specified pattern: D:\a\1\website<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
##[debug]Processed: ##vso[task.complete result=Failed;]Error: No package found with specified pattern: D:\a\1\website<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
##[debug]Deployment failed
Finishing: AzureRmWebAppDeployment
如何将所有这些文件从构建文件夹复制到Azure Web Apps?
已尝试将AzureRmWebAppDeployment@4中的包值更改为各种值...我别无选择...
1条答案
按热度按时间qvtsj1bj1#
当我在部署Web应用程序时在包中添加
'$(Build.ArtifactStagingDirectory)'
和'$(System.DefaultWorkingDirectory)'
时,我收到了与您相同的错误代码。错误:-
我将构建任务中的工件下载到Deploy任务中,并添加了
'$(Agent.BuildDirectory)/**/*.zip'
,因为我的工件是在/home/vsts/work/1/publishedApp
中下载的,而/home/vsts/work/1
的predefined variable是Agent.BuildDirectory
-我的YAML管道:-