Configuring Sonarqube analysis in CI build in VSTS - azure-devops

I am trying to run sonarqube analysis on code commit itself .
I have added 1) prepare analysis configuration and 2) run code analysis, tasks in CI build.
But I am getting an error :
" No agent found in pool mypool which satisfies the specified demands: msbuild visualstudio java
Agent.Version -gtVersion 2.119.1"
Can anyone please guide on what the issue is ?
Thanks in Advance !

Configuring Sonarqube analysis in CI build in VSTS
According to the error message:
error : " No agent found in pool mypool which satisfies the specified
demands: msbuild visualstudio java Agent.Version -gtVersion 2.119.1"
Which means that your private agent does not meet all the demands you set, including msbuild, visualstudio, java, Agent.Version -gtVersion 2.119.1.
So, you should double check if your private agent has those demands, you could move those demands one by one, to check which one is not up to the requirements.
AFAIK, to configure Sonarqube analysis in CI build in Azure Devops, we need following demands:
Make sure the .NET Framework v4.6+ is installed
Make sure the Java Runtime Environment 8 is installed
Install the extension SonarQube from the marketplace
Check the document Analyzing with SonarQube Extension for VSTS-TFS for some details.
Hope this helps.

Related

Azure DevOps Release Pipeline failing

Opened this query in MS Developer Community Forum / Azure DevOps issue
https://developercommunity.visualstudio.com/t/No-agent-found-in-pool-Default-which-sat/10141890?space=21&q=gtversion&entry=problem
Trying to work out why the "Pipeline" runs successfully with my self-hosted docker agent but the "Release Pipeline" fails, it's asking for a version way under the version of the agent I am running
“No agent found in pool Default which satisfies the specified demands: azureps, Agent.Version -gtVersion 2.144.0”
Any given help will be very much appreciated
Compromised installing the PS AzureRM module necessary for the release pipeline tasks to run, and added two user-defined capabilities to the agent to overcome the initial error
Documented the "solution" here
https://developercommunity.visualstudio.com/t/No-agent-found-in-pool-Default-which-sat/10141890

SonarQube & Azure Pipeline ##[error]No agent found in pool '' which satisfies the specified demands: java, Agent.Version -gtVersion 2.144.0

I am implementing SonarQube on my Azure Build Pipeline.
Below is my task pipeline and the error. It will get error on the 3 task I added from SonarQube.
Anyone knows how can I fix this? If I remove the 3 task from SonarQube it works all fine. But I needed the SonarQube.

Error when I run the Visual studio run task in CI

I have a .net application and I am getting below error while running Visual studio task in CI pipeline.
##[error]No agent found in pool TEST APP which satisfies the following demand: visualstudio. All demands: msbuild, visualstudio, Agent.Version -gtVersion 2.115.0
Please let me know how to resolve this.
Your pool does not contain build agents with Visual Studio. You can check your polls and agents on the administration page: Agent pools.
You have to install and register a build agent on a server or virtual machine with visual studio.
Additionally, if your project on Azure DevOps Services, you can use MS Hosted build agents. Update your yaml to:
pool:
vmImage: windows-latest
or if you use classic build, update here:

Project code is not being analyzed for sonarqube

I have a repo in azure DevOps with only folder as test.
Now, I have given the task structure in this way in azure DevOps. But I cannot see the code getting analyzed in sonarqube. The code tab shows blank. Could someone help me with where I am going wrong?? I do not want to give folder name in sources..I want whatever code I add in the branch to be analyzed.
edit: Just realized this is happening only for feature short lived branch..My sonarqube version is 8.0
steps:
task: SonarQubePrepare#4
inputs:
SonarQube: 'connection name'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'pipeline-sonar-demo'
cliProjectName: 'pipeline-sonar-demo'
cliSources: "."
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.exclusions=**/*.xml
SonarQube extension provides three tasks you will use in your build definitions to analyze your projects:
Prepare Analysis Configuration task, to configure all the required
settings before executing the build.
This task is mandatory.
In case of .NET solutions or Java projects, it helps to integrate
seamlessly with MSBuild, Maven and Gradle tasks.
Run Code Analysis task, to actually execute the analysis of the
source code.
This task is not required for Maven or Gradle projects, because
scanner will be run as part of the Maven/Gradle build.
Publish Quality Gate Result task, to display the Quality Gate status
in the build summary and give you a sense of whether the application
is ready for production "quality-wise".
This task is optional.
It can significantly increase the overall build time because it
will poll SonarQube until the analysis is complete. Omitting this
task will not affect the analysis results on SonarQube - it simply
means the Azure DevOps Build Summary page will not show the status
of the analysis or a link to the project dashboard on SonarQube.
It seems you still need add Run Code Analysis task. Regarding how to use SonarScanner for Azure DevOps, please refer to the following documentation:
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-azure-devops/

Why are there no files in my release artifacts directory?

I created a .netcore 2.1 api project and set up Azure DevOps to deploy it to an On-Prem computer using the Windows Agent.
The folder agent_work\r1\a was created on the machine running the agent, however there are no files in it.
I can see that a build did occur and that there is an artifact in my release
What did I miss doing?
[Update]
I can see in the agent job, there is a section which is about downloading an artifact.
It has the error message
There is no build available or the source is not accessible. You can select all artifacts or specify the list of artifacts to be downloaded below.
[Update]
Looks like I need to add a task to the job that is in a stage of my release.
And that task needs to copy the files I want to deploy.
Now the problem is knowing how to specify the source folder.
The strange thing is that it allows me to select a location and then rejects the selected location
There is help that says that if I leave the source folder empty, that will indicate the root of the repo. If I do this the deploy does not error but no files are deployed.
[Update]
I can see in the Get Sources of the Build the message "YOu are in 'detached Head' state. Maybe this has something to do with the problem.
[Update]
In the build pipeline I have
[Update]
When I try to create a new build pipeline I get the following
I select the location to be Azure Repos and the Repository to be vste
then I the azure-pipelines.yml auto-generates as
# ASP.NET Core
# Build and test ASP.NET Core web applications targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://learn.microsoft.com/vsts/pipelines/languages/dotnet-core
pool:
vmImage: 'Ubuntu 16.04'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
[Update]
Looks like I might need to select Use The Visual Designer
[Update]
From ollifant's comment I have found the Publish Artifact task.
Now to figure out how to populate it
[Update]
Uh Uh not looking great
I had not used the ASP NET Core (.NET framework) template when creating the agent job in the build template, so the project was not building correctly.
New build pipeline -> Use the visual designer -> Continue -> ASP.NET Core (.Net Framework)