How to synchronize issues between SonarCloud and TFS - azure-devops

I have a VSTS repo connect to SonarCloud for quality analysis.
I need unique issues source for my team.
When SonarCloud create issues in his system, I want create an equivalent issue in VSTS.
And, when the issue in VSTS closed by a commit, I want close SonarCloud issue.
Can you help ?
Same question with GitHub...
Thx

Although there are issues created during an analysis in SonarCloud, the result is passed. So it won't create bug work item for such builds in VSTS.
The SonarCloud extension itself can not achieve what you want, one workaround here is using SonarCloud api and VSTS REST API to implement your own solution.

Related

SonarQube + Azure DevOps + Pipeline as Code - Is it possible?

The company I work on recently purchased SonarQube Enterprise to improve code quality throughout all repositories. I found out that there is a feature that enables SonarQube to comment automatically on PRs targeting a specific branch, and I successfully managed to try that out.
Thing is:
That configuration is not scalable: I would need to manually configure every repo to follow that rule
That configuration needs a build pipeline to be defined "old school" on Azure DevOps to work, and we are moving into Pipeline as Code, starting of course with CI (where this takes place)
Anyone managed to get the PR commenting working in that scenario? Or, at least, solving the #1 problem?
Cheers
You can use REST APIs to do whatever configuration you need to do across your repositories. Refer to the REST API documentation.
Shouldn't matter, although I haven't tested it. The SonarQube tasks aren't aware of whether the build source is YAML or visual designer/classic/JSON builds. The underlying tasks and job running architecture is the same. As long as the build is hooked up to a branch policy, it should still work.

Reuse Github Actions self hosted runner on multiple repositories

I have a Self-Hosted Github Actions runner running on my server for 1 of my repositories. But now I want to use that same runner for an other repo.
Is there a way that I can reuse that same Github Actions runner for an other repo without the need of creating a new runner?
Update:
This is possible as of 22nd of April 2020.
You can now share runners across an organization.
This allows for repositories within your organization to use those runners.
https://github.blog/2020-04-22-github-actions-community-momentum-enterprise-capabilities-and-developer-improvements/#share-self-hosted-runners-across-an-organization
Old Answer:
This is not possible as of yet, according to a Github Partner:
Currently, we have no methods to use the self-hosted runners across repositories, and also have no options to added self-hosted runners on Organization level.
Source: https://github.community/t5/GitHub-Actions/Can-one-Github-Actions-self-hosted-runner-work-for-multiple/td-p/41465
For those that want to know what I did to fix this problem. I installed multiple GitHub runners on my server with different names. Not the best solution, but the only thing thats possible now without a dirty workaround...
We're using auto-scaled self-hosted github action runners on AWS spot instances.
We've open-sourced it: https://github.com/philips-labs/terraform-aws-github-runner
One of its creators make a blog post about it with some information about the workings: https://040code.github.io/2020/05/25/scaling-selfhosted-action-runners
Once a runner is active it can pick up multiple builds from various repositories. After a while, the idle runners are terminated. When a new workflow is triggered, a github app will create a new runner and that runner will pick up the work.
Now the organization account can create a github runner and use it in all repositories.

VSTS-GITHUB Workflow

Please elaborate the steps to create a workflow of Visual
Studio Team Services and Github.
Integration of Github with VSTS and creating a workflow.
Once we create user stories in vsts, is there any way to create a
transition from one state to another(New->Active->resolved),
based on repository update(github).
There is a way to transition from on state to another when github repo is update:
Create a CI build definition for the github repo.
Add a power shell task to change the stories state.
But usually user stories are linked with repo on VSTS not github, that’s more useful and meaningful.
Automatically is only using VSTS git repo.
If you like update this, you need to create a manual integration, possible using the VSTS Rest Api.

Team Services - Create issue in Github on failed build

I am using Github as my repo as well as my Kanban/Scrum board. We use Visual Studio Team Services for our automated builds. We really like the way VSTS works and it works well with Github as the repo.
However, I want to be able to create a new Github issue/bug if and when our Continuous Integration build fails. I know you can create a VSTS Work Item but I would rather keep all issues centralized.
Is there any way to hook up VSTS to create a Github repo whenever a build fails? Or perhaps create a Github issue whenever a new VSTS Work Item is created?
We are running our own build server so possibly something can be done on that end?
Yes, you can create a github issue when VSTS build failed with two options.
Option1:
In VSTS build definition, add a powershell task in the end of the build process. Functions in the powershell should include:
Detect above build tasks in the build definition. Use REST API timeline to get build detail, you can find each task result in result parameter.
Determine to create a github issue or not. If all above build tasks are pass to build, don’t create github issue. Else, create a github issue by github API.
Option2:
Create your own website, and in VSTS use web hooks to tigger build fail information for your own website. After your own website receive the build information, it can create a github issue.

Trigger Visual Studio Team Services build for a GitHub Pull Request

How do you get VSTS to build when a PR is created in GitHub? I've tried several triggers in the VSTS build like refs/pull/*/merge and refs/pull/*/head. I have a build working when a commit is made to the master branch, but I can't get a build to trigger when a PR is created.
I get the following when a PR is created.
Also, the webhook history shows that a message was successfully posted to VSTS, but the build never starts.
The official Microsoft VSTS GitHub Integration extension now supports this directly.
I think it's the trigger. Try what's described in this blog post.
There is not an easy way to enable this today for PRs. It is on the VSTS feature backlog that we want to address soon.
The way to make it work today would be to do something like: add a webhook to call your own custom service endpoint. Within your service endpoint, you could then call into VSTS to queue a build, and the build would need a step to post success/fail back to GitHub.
In your custom service endpoint, you would need to make sure the user is authorized as a contributor on the GitHub repo.
On the new VSTS UI you can find it in Build Edit -> Triggers: