Azure DevOps Create Work Item From Selected Code - azure

I want to preface this with I tried to submit this in the developercommuinty.visualstudio.com Request a feature section and it wouldn't upload due to server errors, 403 and bad requests.
On-prem DevOps version: Server 2020 (18.170.30331.4)
Scenario
I was going through some code with another team as they were asking questions it. The code in question was connecting to a database and then querying a different database. So now, a bug has been identified and I was looking to create one that calls out this specific line of code. When highlighting it in the repo and right clicking, there wasn't a way to create a task from it.
Expectation
I was expecting a similar experience to what GitHub has and create a work item that points to the specific line of code.
Suggestion
Mirror that similar functionality from GitHub in Azure DevOps when selecting lines in the repo and being able to create a work item from it.

Related

How to add test result attachments during Azure Devops build or release via a C# application?

I'm wanting to add some test case attachments during a build or release but I'm struggling to find a valid approach to do this. I'm not using MSTest.
I tried creating a custom build/release task but I've found the azure-devops-node-api package to be flaky at best, and seemingly lacking contributors.
This is what I would hope to do...
Use C# if possible
Have the code/task available for either a build or release across multiple repositories and projects (same organization) without code duplication
Automatically authenticate with the currently running build/release without needing PAT tokens or any other form of authentication
Access to both Azure File Storage and Azure Devops
Works with any build or release agent
Is this achievable? I've seen odd articles in various places but nothing like whats described above. For example this shows promise in terms of validating the current build/release in a C# application however it is 4 years old now and doesn't explain how to integrate with a pipeline.
Can anyone help?
Thanks,
I've always leveraged mstest, so within the runner we've had access in c# to the TestContext that supports adding the attachements directly to the test result.
It looks like the API is exposed for adding attachments to the runs though, so I would think you can create something either in c# or in powershell that accomplishes what you are asking. You will likely need to make sure the agent phase has access to the OAuth token.
POST https://dev.azure.com/{organization}/{project}/_apis/test/Runs/{runId}/Results/{testCaseResultId}/attachments?api-version=5.1-preview.1

better pull request manager for azure dev ops

I am using Pull Request Manager Hub from the marketplace for our azure dev ops projects/repos. id like something that has a cleaner UI. It seems too busy and like everything is a button and some of the icons don't show up completely. I don't want to complain too much but is anyone using something else that they like more? My main requirement is that I should be able to see all pull requests across repositories in the same project.
I’m the creator of Pull Request Manager Hub and new improvements (better UI, lots of new features) have been released to address some of the main complains. Also, feel free to open issues in the GitHub repo where we try to fix as soon as possible.
Thanks ;-)
My main requirement is that I should be able to see all pull requests
across repositories in the same project.
For this demand , you can use Pull Request Search extension. This extension allows pull requests to be filtered by status, creator, reviewer, title, start date, end date, and repository. You can specify different repos in the same project in the Repo drop-down list.
Another extension Pull Request Dashboard can also view pull requests across all repositories. But it has a flaw, you can only see the pull requests with active status.
https://marketplace.visualstudio.com/items?itemName=mimeo-vs-marketplace.mimeo-active-pull-requests has a plugin called 'All Active Pull Requests' (among others) is the best I have found so far.

gitlab API - how can I create a branch from an issue

In git lab, you can create an issue, then within the issue you can create a branch. This branch is linked to the issue (I think because of the issue number at the start of the branch name), such that when you do a merge request on that branch it automatically closes the issue.
So my question is - how can you do this via the API? I can create the issue, but there is no control (as far as I can see) within the issue API to create the related branch.
Is that possible?
It would be nice to be able to create an issue with branch in one go - but I don't think that is possible?
Ok - its not perhaps the best answer, but here is what I came up with for a interim solution (in linux bash):
Raise the issue store response in cmd_resp
Extract the issue ID: echo $cmd_resp | grep -o -P '(?<=iid":).*(?=,"project_id)'.
Where the issue ID is found by looking for: iid":<ISSUE-ID>,"project_id
Create a branch with the name: <ISSUE-ID>-some-branch-name - by having the issue ID at the start of the branch name, gitlab automatically makes a relation to that issue.
So - its quite a simple approach, but it does not feel very integrated. I would still prefer to do that from the point of view of the issue.
It is not possible to create a branch related to an issue via the issues API.
However, this is in line with how RESTful APIs should be designed. If you want to create a branch, you need to make a POST request to the branches API.
POST /projects/:id/repository/branches
As you have already found out, GitLab is quite good at automatically linking issues, MRs and branches together.
For a branch to be linked to an issue, simply start the branch with the issue ID. However, usually it is enough if a merge request is linked to an issue. In my opinion, you shouldn't really be concerned with the branch. You can later access the branch via issue->MR->branch
Merge requests are linked to issues whenever a MR's description text links to an issue (e.g. #1). If you add an issue ID to the Closes statement, the issue will also be closed upon MR resolution.
Therefore, you could simply create a branch via the API, name it however you want. Then, create a MR from that issue and include Closes #1 in your MR description, where 1 is your issue ID.
Further, I would recommend using a more sophisticated REST client. You shouldn't have to parse the issue ID yourself. It is properly set as a field in the JSON response.

Deploy two VSTS repositories to one Azure web app

Let's say I have an Azure App Service web app at foo.azurewebsites.net. The code for the web app (a simple Node.js server and React frontend) is hosted on VSTS, and a custom deployment script is configured build and deploy the web app every time code is pushed to the repository's master branch. In other words, the standard web app configuration.
Now, all of my API code (just a Node.js server) is in another repository on VSTS. I'd like to be able to do the following:
Have all requests to foo.azurewebsites.net/api be handled by the API server (an implication of this, which I would nonetheless like to state explicitly, is that the server can ask the browser to set cookies that the web app can then read, and vice versa).
Set up similar continuous deployment for the API server, such that it gets redeployed whenever there are code changes in the API repo.
Be able to maintain the web app and API repositories completely separately.
This seems like a fairly standard scenario...is there an accepted solution? I came across this, but it seems like a pretty hacky way to do it, not to mention the fact that I have no idea what the correct URL is for the web hook for VSTS and can't seem to find any information on it. Also, that example doesn't cover how to deal with point (1) above.
EDIT: Additional clarification
Note that the accepted answer on this question is not what I'm looking for. It describes how to pull from a second repository at deployment time, but not how to have that second repository trigger deployments, or how to handle the fact that the the second repository is its own server. Additionally, it introduces a dependency between the two repositories, since the deploy.cmd is presumably under source control in the first repository.
EDIT: Virtual Directories
Thanks to #CtrlDot for pointing out that Virtual Directories are the way to solve (1). Still seeking guidance on (2) and (3).
I think the concept you are referring to is called Virtual Directories
I'm not sure which VSTS task you are using to deploy, but based on the article provided, you should be to configure it to target only the virtual directory you want to deploy to.
EDIT
Sorry for not being more clear. The AzureRmWebAppDeployment task has a parameter for virtual application name. You would simply set that in your deployment pipeline for the API project (/api) and for the main project (leave it blank)

Setup Continuous Deployment with DropBox on Windows Azure Website

Where I work, our marketing team is looking for a "quick and easy" method up periodically updating some files on a website of ours. I opened my mouth and said "We can use Azure Websites with DropBox!". It all works fine, except that with DropBox, files only deploy if I log into the Azure Portal and click Sync. Needless to say, this is a deal breaker, because the users want to save a file and have everything appear magically.
Is there a way to setup continuous deployments via DropBox on Azure? I don't mind setting up a job to run every 15 minutes to perform a file upload if needed.. but would prefer to avoid that if possible
Thanks In Advance
Currently we don't support the continuous sync with Dropbox. The challenge is the noise and the reliability of the site given those changes. Imagine users naturally modify file by file and Dropbox sync them one at time. You can get into the situation where your site is in transient bad state.
This is not currently possible using the Dropbox integration in Azure Websites. Best option for this is the local git integration, where Azure will provide you a remote git location that you can push to that causes an update.
So that gives you behavior, but not the dropbox behavior you want, as someone would still need to commit and push.
To get that you could look into implement a Git hook to mimick the behavior, where you would auto commit and push when a file changes.
Something like this would give you that behavior, but you'd need to translate to a server-based model.
Git Repo Auto-commit and Push
Alternatively, you can host the site in GitHub or Visual Studio Online and I beleive you get that hook automatically.

Resources