Azure Pipeline build specific pull requests - azure-devops

I have a list of pull requests, each linked to the specific work items. I want to run a pipeline only for some of the work items. Therefore I would like to somehow automatically cherry-pick only commits/pull requests related to work items I want to build. Either using tags on work items or something similar. In the build, I need only the files which were changed, so I was thinking of using git diff.
Is that possible using the Azure Pipelines?

If I understand your request correctly, you need to run the build pipeline only for those pull requests which meet certain requirements, for example, are linked to the work items tagged with specific words. Although I'm sure there's no out-of-the-box solution to this, I think it is possible to achieve with the Conditions concept and the REST API.
I would follow these steps:
The very first build step in the build job should be a script to find out if this particular pull request being built is related to the target work items. It can be a PowerShell build step, which should:
Get the pull request ID - it is available as a predefined system variable called System.PullRequest.PullRequestId
Make a REST API call to get work item IDs related to this pull request. It will return a collection of {id, url} pairs, where id is an ID of the work item in question
For each found work item ID, make a REST API call to get the details of the work item, in particular, you're interested in the System.Tags property of the response
Again, for each work item, parse the System.Tags property value to find out if it contains necessary tags
If at least one related work item contains the tags you're interested in, set the flag variable called i.e. ShouldRunTheRestOfThePipeline to true
Conditionalize the further steps of the job with the custom condition. You can read more about the syntax of the expression here. In particular, the Q&A section describes how to use the variable set in the previous build step in a subsequent step's condition
Now, regarding your notes about taking only changed files. In fact, the pull request nature is to keep the changed files compared to the target branch it is created against. So, you don't need to do any extra actions to git diff - the pull request already contains all you need.
Finally, I would suggest you reconsider the requirements of this setup, 'cause it sounds a bit unnatural to me. There are other options for how not to trigger a pipeline. For example, it can be decided based on the branch/tag name, both include and exclude options are available. Or, you can specify file paths to include or exclude, for instance, never trigger a pipeline if only docs/* were changed. The wildcard syntax is supported, which makes this tool even more flexible.
Hope this can help you build a suitable solution to your specific scenario.

Related

GitHub: filter for issues that are either assigned to somebody or somebody is mentioned

Is there an option how to show all issues that are either assigned to me or that I'm mentioned in at the same time? Filtering by using the dropdown menu allows only to check for one of those and using is:open assignee:#me mentions:#me filters for all issues for which both constraints are true (basically & instead of |)
The first answer to this question from 8 years ago suggests it is not possible to use an "or" query. Does this still hold true?
What is the best alternative to filter for all issues that are relevant for me, ideally in the whole organization - third party tools?
The involves:user may be useful here:
Search by a user that's involved in an issue or pull request
You can use the involves qualifier to find issues that in some way involve a certain user. The involves qualifier is a logical OR between the author, assignee, mentions, and commenter qualifiers for a single user. In other words, this qualifier finds issues and pull requests that were either created by a certain user, assigned to that user, mention that user, or were commented on by that user.
Simply searching for the user's Github handle may be useful too.
Using a tool like gh (github cli) will allow you to lest and filter items too. A script can easily concatenate the results:
gh issue list --search "involves:#me is:open"
You can have it spit out json as well by adding --json, that way you can parse and further process the results as well.

Is it possible to find all objects that are not related in Azure Data Factory?

I have inherited an Azure Data Factory solution in my new job. It has been worked on by at least 6 different BI developers. I'm currently busy with cleaning up my Azure Data Factory, fixing version control, and making sure that all my three environments are the same.
Some objects seem obsolete to me. To check if it is obsolete, I go over to the portal, and check the objects Properties if it is related to another object.
If not, it is a confirmation for me that the object is not (yet) used and I can safely remove it from the solution.
Is there an easier way than checking each object?
I figured it out and wanted to share it here. It is possible to check the "orphaned" objects in an ADF instance, however not directly from the UI. Paul Andrew has an excellent blogpost about his script that is able to check your ADF code against his best practices. The relevant checks for me are:
Pipeline(s) without any triggers attached. Directly or indirectly.
Dataset(s) not used by any other resource.
Trigger(s) not used by any other resource.
Linked Service(s) not used by any other resource.
The last check can also be done via UI, see #AbhishekKhandave-MT answer.
Step 1: Export ARM template to a local folder, and unzip it
Step 2: Download Paul Andrews PowerShell script from here
Step 3: Open the script and replace the $ARMTemplateFilePath variable with the path to your ADF ARM template. If you want to check out the details, change the $VerboseOutput variable to $true
Step 4: Run the script and check the results.
Here are my results, so 58 datasets are not used by any other resource.
Unfortunately, there is no other way to find whether object is used(yet) or not.
But you can check number of datasets linked with a single linked service as shown in below screenshot.
Manage > Linked Services
Click on number in Related column.

Azure DevOps Migration - Moving Project to Another Org

I'm looking to migrate a project from one org to another in Azure DevOps. We've ended up with two or three orgs, and this project that I'm looking to move has all sorts of weird and wonderful work items created and custom fields added. What I'm looking to do is move the project and then see if I can persuade the powers that be that certain things can be dropped but I have an immediate need to move as-is so that reporting and other work isn't impacted.
I have tried to get this to work with the migration tools (and tried to follow the videos) but have hit a dead-end. I think there are two issues potentially. One being the ReflectedWorkItemId. It says that it's not found in User Stories but I'm not sure how to resolve this? Do I go into user stories and add a field called 'ReflectedWorkItemId' and populate it with the work item number and/or add the same field in the destination org process?
It also mentions in the info that it can't find one of the Work Item Types - Processes. There are a few other custom work item types that have been created too but I assume it's given up on the first one. Do I have to create all of the work item types and the custom fields for each work item type in the destination org? Or am I getting the wrong end of the stick with this?
To provide sync as well as migration it is important that the tools knows which items have already been migrated. This is the purpose of the ReflectedWorkItemId field.
The field is not required in either case, however... if you don't have
the field then the system cant be re-run as it will re-copy all
completed work items. If you add the field to the target then it will
only copy those items it cant find. If you add the field to the source
(yes it needs to be the same refname), and set UpdateSoureReflectedId
to true then you can also filter the source, using a query and limit
what you load.
The former prevents duplicates, and the latter allows you to filter
the data load...
This is mentioned in this document. Here is a similar issue you can refer to.
TF201077 that usually happens when the target Project does not have a work item of that name. You can refer to this issue on github for help.

Is it possible to build a process with a work type like test case in azure dev ops

Good day all,
I am trying to build a custom work item type in azure dev ops. i really like the functionality of the test case steps feature. Its a table, with simple navigation and CRUD operations. However, when you go to inspect how test cases builds this feature, all it says is "Textbox (multiple lines)". Which isn't the case.
Does anyone know if it is possible, or if there is an extension to add tables as a field to a work item type?
If you want to customize a work item field like the "steps" field of the test case , I am afraid this demand is not feasible. I also tried to add a field by using an existing field (Steps),but this not works,the actual field still displays like text.
The Steps field is used to support Test case management. So I think this field is specific to the test case. For details ,you can refer to this docs.
You could also submit a suggestion ticket to suggest the new feature through this url.

Github API V3 Search Repo issues

I'm trying to get 3 repos with highest numbers of stars in given language. I have 3 issues with it:
search is using legacy pagination style and per_page does not seem to work
language parameter is also not respected, I get php, java etc
i'm sorting by start but in result i get detailed repo info with everything
but stars count...
curl "https://api.github.com/legacy/repos/search/foobar?sort=stars&order=desc&language=VimL&per_page=3"
First of all, per_page isn't listed as an accepted parameter. With that in mind, it could be invalidating the rest of your parameters being sent. If removing that does in fact fix the issue, you should contact GitHub support directly. If in fact you do this, be sure to include "API" in the topic so it gets routed directly to the API team so you can get your answer faster.
Re:
i'm sorting by start but in result i get detailed repo info with everything but stars count.
The legacy API (as you already noted this was) returned old style (v2) Repository information. If you want information about the stars you'll have to make a direct call to /repos/:user/:repo after you find the repositories you want.