Azure Devops: Error: No package found with specified pattern: D:\a\1\s\**\*.zip - azure-devops

I'm trying to set up my first pipeline to deploy a web app to an Azure App service. I am able to manually publish the site via Visual Studio but now I am trying to get it build and deploy from an Azure Repo. The build part works fine and without errors. The problem comes in when I add in the deploy task. The deploy task doesn't seem to be able to find the file/s to deploy.
My Pipeline
My Publish config:
In my Pipeline the Publish section shows the following debug info:
##[debug]Exit code 0 received from tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]modifyOutputPath=true
##[debug]Zip Source: D:\a\1\a\s
##[debug]Zip arguments: Source: D:\a\1\a\s , target: D:\a\1\a\s.zip
##[debug]Successfully created archive D:\a\1\a\s.zip
##[debug]rm -rf D:\a\1\a\s
##[debug]removing directory D:\a\1\a\s
The Publish Artifact config section:
The Publish Artifact section shows the following success message:
File upload succeed.
Upload 'D:\a\1\a' to file container: '#/10370704/drop'
Associated artifact 541 with build 667
The Web Deployment config looks like this:
Then the Azure Web App Deployment shows the following debug and error message:
##[debug]pattern: 'D:\a\1\s**.zip'
##[debug]expanding braces
##[debug]pattern: 'D:/a/1/s/**/.zip'
##[debug]applying include pattern against original list
##[debug]0 matches
##[debug]0 final results
##[debug]No matching files were found with search pattern: D:\a\1\s**.zip
##[debug]Deployment Failed with Error: Error: No package found with specified pattern:
D:\a\1\s**.zipCheck 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\s***.zip

You can try to use powershell task to list the files in the folder before publish the Azure Web App.
From your description, it seems the pattern should be $(Build.ArtifactStagingDirectory)/*.zip?

Related

Azure Pipeline Consuming Azure Artifact Nuget - NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/... (Q&A)

I am trying to have my Azure Pipeline get Nuget Packages from my Azure Artifacts feed, but they don't want to talk to each other.
I have followed this document and '[Project name] Build Service ([Organization name])' already seems to have rights, but I'm getting the following error.
##[error]The nuget command failed with exit code(1) and error(NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/.../.../nuget/v3/index.json.
My build is unchanged from before.
What should I do? (Q&A Below)
After a lot of trial and error, this seemed to be the fix:
Go to Artifacts > your artifact feed > 'Connect to feed' > Nuget.exe and copy the nuget config. Create a file called nuget.config at the same level as the sln (could be csproj level) and paste in the contents.
In Artifacts (Artifacts > Settings Cog > Permissions) You need {project name} Build Service ({organization name}) AND Project Collection Build Service ({organization name}) to have at least 'Collaborator' (you can have contributor) rights as documented here.
In the build, two additional steps were required (might need to overwrite the existing nuget installer). I found this that referenced the Nuget Authenticate, and I also needed to install the Azure Artifacts Provider. Start of the build shown below (was previously just the NugetToolInstaller step).
steps:
- task: NuGetToolInstaller#1
# Required for custom access to Artifacts
- task: PowerShell#2
displayName: "Install Artifacts Provider"
inputs:
targetType: 'inline'
script: |
Write-Host "Install Artifacts Provider"
Invoke-Expression "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx"
# Check we can authenticate
- task: NuGetAuthenticate#1
displayName: "Nuget Authentication"

YAML file build issues github nuget repo 404

I have this YAML file that has something similar to this code inside it
- name: Build solution
run: msbuild /p:Configuration=Release /p:Platform="Any CPU" .\SomeLargeSolution.sln /t:build /bl:${Env:ARTIFACTS_LOCATION}/logs/build.binlog
When this step runs in the build process I get something like this error:
PublishNuGet:
nuget.exe push "NuGet\*.nupkg" -Source "GPR" -SkipDuplicate
WARNING: No API Key was provided and no API Key could be found for 'https://nuget.pkg.github.com/SomeNugetGitRepo'. To save an API Key for a source use the 'setApiKey' command.
Pushing SomeNugetPackage.Integration.Model.4.2.4.346.nupkg to 'https://nuget.pkg.github.com/SomeNugetGitRepo'...
PUT https://nuget.pkg.github.com/SomeNugetGitRepo/
WARNING: Please use the --api-key option when publishing to GitHub Packages
NotFound https://nuget.pkg.github.com/SomeNugetGitRepo/ 229ms
Response status code does not indicate success: 404 (Not Found).
I'm wondering where these nuget settings are configured.. For instance how do I set the value of the source "GPR" maybe I want to change the source to https://nuget.pkg.github.com/SomeOTHERNugetGitRepo?

SonarQube/Azure DevOps code analysis failure - .scannerwork/report-task.txt not found

We run automated code-quality scans in SonarQube that are triggered by pipelines in Azure DevOps:
# retrieve and build code, run unit tests etc.
- task: SonarQubePrepare#4
displayName: 'Prepare SonarQube Scan'
inputs:
SonarQube: 'SonarQube DevOps Connection'
scannerMode: 'CLI'
configMode: 'file'
- task: SonarQubeAnalyze#4
displayName: 'Run SonarQube Scan'
- task: SonarQubePublish#4
displayName: 'Publish SonarQube Scan Report'
inputs:
pollingTimeoutSec: '300'
About a week ago, the main analysis task ('Run SonarQube Scan') began failing for all pipelines with the following error:
...
##[error]ERROR: Error during SonarQube Scanner execution
ERROR: Error during SonarQube Scanner execution
##[error]java.lang.IllegalStateException: Unable to load properties from file /home/vsts/work/1/s/.scannerwork/report-task.txt
java.lang.IllegalStateException: Unable to load properties from file /home/vsts/work/1/s/.scannerwork/report-task.txt
...
##[error]Caused by: java.io.FileNotFoundException: /home/vsts/work/1/s/.scannerwork/report-task.txt (No such file or directory)
Caused by: java.io.FileNotFoundException: /home/vsts/work/1/s/.scannerwork/report-task.txt (No such file or directory)
...
We have made no changes to our pipelines, so I am mystified as to what has caused this change.
We are using SonarQube Enterprise EditionVersion 7.9.1 (build 27448) (on-premise installation) and version 4.9.0 of the SonarQube extension for Azure DevOps (published by SonarSource).
UPDATE 25/3/20 (thanks to patricklu-msft):
We are using a Microsoft-hosted build agent with an ubuntu-16.04 image. Running the pipeline in debug mode reveals the following:
2020-03-25T14:25:00.3694399Z 14:25:00.369 DEBUG: Report metadata written to /home/vsts/work/_temp/sonar/20200325.2/eec0f38a-913b-3db3-e1b2-71091ea5f860/report-task.txt
So it appears that the report metadata are being written to /home/vsts/work/_temp/sonar/20200325.2/eec0f38a-913b-3db3-e1b2-71091ea5f860/report-task.txt but SonarQube subsequently looks for them in /home/vsts/work/1/s/.scannerwork/report-task.txt. It looks like there is a mv operation missing somewhere ...
Not sure if it's a SonarQube task side related issue.
According to this link here:
The new version (4.7.x) is looking here:
##[debug]adjustedPattern: 'C:\AzureDevops\Agent2-GCS-Docker\_work\_temp\sonar\199416\**\report-task.txt’
Looks like it's supported to look the report-task.txt in temp folder with new version.
Try to roll back your task version and check if this do the trick.
Closer inspection of the Azure pipelines logs revealed these two entries that weren't there before:
2020-03-26T15:26:44.0989881Z INFO: Executing post-job 'Forbidden Configuration Breaker'
2020-03-26T15:26:44.0990841Z INFO: Executing post-job 'Quality Gate Breaker'
Someone installed the Sonar Build-Breaker Plug-in a week ago without telling us, and none of us have correctly configured it in our pipelines yet. Setting it to skip the quality gate check (sonar.buildbreaker.skip=true) effectively by-passes it (although those two log entries still appear) and the pipelines run successfully once more.
Update 24/04/2020: I have now upgraded the Build Breaker plug-in to v2.3.1 (build 347) and that seems to have fixed the issue.

Analyse Javascript/Typescript project with SonarCloud and Azure DevOps

I have a project containing both Javascript and Typescript files. I'm using SonarCloud to analyse this project from an Azure DevOps pipeline.
I set the task Prepare Analysis Configuration in my build pipeline like this:
- task: SonarCloudPrepare#1
inputs:
SonarCloud: 'Sonarcloud'
organization: 'MyOrg'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'My key'
cliProjectName: 'My name'
cliSources: '.'
When running the pipeline, I have the following error in my pipeline on Sonar Cloud Analyze step
INFO: Found 1 tsconfig.json file(s): [/home/vsts/work/1/s/tsconfig.json]
##[error]ERROR: Cannot find module 'typescript'
##[error]ERROR: TypeScript dependency was not found and it is required for analysis.
ERROR: Install TypeScript in the project directory or use NODE_PATH env. variable to set TypeScript location, if it's located outside of project directory.
ERROR: TypeScript dependency was not found and it is required for analysis.
ERROR: Install TypeScript in the project directory or use NODE_PATH env. variable to set TypeScript location, if it's located outside of project directory.
##[error]ERROR: Missing TypeScript dependency
The analysis works well for javascript files but not for typescript files. I have the typescript package installed as dev dependency in my package.json but it seems it is ignored by SonarCloud.
The documentation and topics I found are related to SonarQube version but I can't figure out how to setup this with SonarCloud.
By default, node_modules folder in local project folder won't be added into source control if you're using Visual Studio.
And this error would occur since Run Code Analysis task can't find the dependency packages defined in your package.json file. My reproducible step:
Then I add one npm install task before Prepare Analysis task to install missing packages:
NodeJS is my project name. Also in Devops repos, this is the name of the folder where package.json exists.
Then this issue went away in my pipeline:
Hope it also helps for your issue :)
In addition: You can also choose to add local node_modules folder into source control if you want. But this is not recommended in Azure Devops Service.

Publishing to Symbol Source from Team City

For awhile in my Team City build, I am unable to publish my source NuGet packages to symbolsource.org as it responds with 500 Internal Server Error.
[16:02:36][push] Pushing NCode.Composition.DisposableParts 1.0.1 to the symbol server (http://nuget.gw.symbolsource.org/Public/NuGet)...
[16:04:18][push] Failed to process request. 'Internal Server Error'.
[16:04:18][push] The remote server returned an error: (500) Internal Server Error..
[16:04:18][push] Process exited with code 1
I am able to publish my normal packages to NuGet.org just fine. I believe that I have properly configured everything as documented by symbol source.
https://www.symbolsource.org/MyGet/Wiki/Publishing
http://www.symbolsource.org/Public/Metadata/NuGet
https://www.symbolsource.org/Public/Account/Register
Here is my Build Step configuration for NuGet Publish:
Runner Type: NuGet Publish
NuGet.exe: Default 2.8.6
Packages: *.nupkg
API Key: (my personal API key from NuGet.org)
Package Source: (blank)
In my build output directory and artifacts recognized by TeamCity, I do have both of my packages in there:
NCode.Composition.DisposableParts.1.0.1.nupkg
NCode.Composition.DisposableParts.1.0.1.symbols.nupkg
Any assistance would be appreciated!
I think that the problem is with two packages with the same name. Did you try a workaround with another build configuration and snapshot dependency?
I'm using another build configuration with snapshot dependency to build which produces *.nupkg and *.symbol.nupkg. Artifact dependency is set to:
-:*.nupkg => <replace with location>
+:*.symbol.nupkg
The build configuration only publishes *.symbol.nupkg to symbolsource.org.