SonarQube Build Breaker version update for Multiple Projects in TFS - tfs

Is there a way to SonarQube Build breaker for multiple projects in TFS. As we have more than 100 projects in TFS, now we are updating the SonarQube Build Breaker version and we do not want to go each Build Definition and want to automate it.

You can make a script using TFS REST APIs to update build process task version.
Get Build Definition
In this link you have do documentation to use the TFS rest apis.
The JSON path to find the version spec of the task is
rootObject.process.phases[0].steps[sonarqube build braker task
id].versionSpec

Related

How to update dacpac version during build process to be build number of the queued build?

I am trying to update the version element in the DacMetadata.xml file of a .dacpac to match the build number of the build where the .sqlproj is being built. I would prefer to do this in PowerShell, but can do it in C# if necessary.
I am using on-prem TFS 2018 and the vNext build.
There is already an extension exists to version dacpac, you can check and test it:
https://marketplace.visualstudio.com/items?itemName=richardfennellBM.BM-VSTS-Versioning-Task

TFS Build not adding folder to SonarQube

We have introduced SonarQube to our project integrated with TFS Build (2017).
That is our project structure:
SonarQube should run over App, DotNetNuke and LotesKWKPortal
The problem is that Sonar is adding only KWKPortal and LotesKWKPortal, the App folder is ignored:
Is this a problem with the Build definition or with SonarQube?
It seems like Sonar is only analysing folders with .sln files. How do I tell my TFS build to consider all folders in the repository?
EDIT:
That is how our build definition look like:
You're using the SonarQube scanner for MSBuild tasks. Per the docs, you should use the SonarQube CLI task for anything not touched by MSbuild, such as JavaScript.

Commit file back to repository from build server in Visual Studio Team Services

I'm currently setting up continuous integration using TFS/Visual Studio Team Services (was VS Online), and I'm using the Team Foundation Build 2015 tasks. So not the XAML builds.
I'm using it to build a Xamarin Android project, but that's pretty irreverent I guess,
The process should be like this:
After a check-in:
TFS should download the sources
TFS should increment the version number within AndroidManifest.xml
I've managed to do this by making a PowerShell script for this.
After the AndroidManifest.xml file is modified, it should be committed back into the TFS repository
Then the rest, build deploy into hockeyapp etc
The first steps are all configured, but I'm struggling with the commit part. How do I get TFS to commit the file? I don't really see any task suitable for it. I've tried using the Copy and Publish Build Artifacts Utility - But that did not seem to work, and I'm not even sure if that's the right utility
I'm using the default hosted build agent btw. Any help would be appreciated
Warning
I do want to point out that checking in changes as part of the build can lead to some features of VSTS/TFS not working. Association of work items to the checkin, sources and symbol generation, tractability from changes to build to release and integration with Test Manager, remote debugging, will likely not yield the expected results because the Changeset/commit recorded in te build may not match the actual sources. This may lead to unexpected funny behavior.
Also, if any new changes have already been committed/checked-in after the build has started, the version number may be updated in Source Control for code that was not actually released under that version.
So: First of all, it's considered a bad practice to change the sources from the build process.
Alternatives
There are better ways of doing it, one is to use the build version (Build_BuildNumber or Build_BuildID variables). Alternatively you an use a task like GitVersion to generate the semantic version based on the branch and tag in your git repository. That way your build will generate the correct version number and will increment the revision in case the same sources are built multiple times.
I understand, but I still want to check in my code as part of the build
If these things don't work for you and you still want to check in the changes as part of the build, you can either use the TFVC Build Tasks if you're using TFVC or use the Git Build Tools to add the remote to the local repository and then use the git commandline tools to commit and push the changes back to the repository.
These extensions require TFS Update 2 to install. But you can push the individual build tasks using the tfx commandlien tool. For the TFVC tasks the process is explained here.
On mac
On the mac it's going to be harder since you're using TFVC. My TFVC tasks leverage the TFS Client Object Model and Powershell to communicate to the TFS Server. The tf.exe tool doesn't even work on windows when you're in the context of a build, which is why I need to call into the VersionControlServer object directly. Given I'm dependent on these technologies, the tasks won't run on a Mac or Linux agent.
You could try to see whether the Team explorer Everywhere X-platform commandline works from the build agent (using a shell script). I have no way to test this on an actual Mac.
Given the cross platform nature of your project I'd recommend to move to Git, it integrates into XCode and Android Studio, making it easier to do a native UI or build on top of native libraries.
Alternative 2
You could setup a build which does the required changes to the code and then checks in the modified code. Then have a (CI) build run the Android and the Mac builds using the modified code.

Adding TypeScript handler to TFS Build vNext Agent

I'm attempting to set up a Xamarin iOS build on an internally hosted TFS 2015 build server. We have been working with this for a few months now and have used many of the contributed build tasks on GitHub and written a couple of our own.
So far we have only used tasks written using NodeJs and PowerShell. The Xamarin.iOS task is written using TypeScript and it seems our build agents don't have the required handler for this. We get this error when trying to run a build.
The definition for the task does not have a handler that matches any supported by this agent. Supported handlers: AzurePowerShell, AzurePowerShellHandler, PowerShell, PowerShellHandler, PowerShellExe, PowerShellExeHandler, Process, ProcessHandler
I'm not sure how to add this capability to the agents. Can anyone help?
Xamarin.iOS build task requires a Mac OS build agent, refer to this link for the configuration: Xplat build agents
Another reference may help: http://developer.xamarin.com/guides/cross-platform/ci/configuring_tfs/

Build vNext missing tasks

I'm currently working with TFS Build vNext.
I've seen lots of tutorials and I've found out that many vNext build tasks are missing in my Build vNext. Tasks like "Publish build artifacts" or "Powershell on target machines" are not in my list of available tasks.
I've been looking for a solution or a way to upload the tasks to my TFS (if there is any), given that these tasks are public to download and extend but haven't found anything.
Does anyone know how can I have these tasks available? I'm running TFS 2015.
It sounds like you're using RC1. RC1 was an earlier iteration of the new build system and thus doesn't have a lot of the tasks that RC2 has.
There is a Node application in the GitHub repo for the build tasks for uploading tasks, but I haven't sat down and used it so I can't say for certain it will work.
https://github.com/Microsoft/vso-agent-tasks/tree/master/TaskUploader

Resources