Searching for all TFS changesets based on a check-in Comment - tfs

Is there a way to search TFS using PowerShell to find all changesets that contain some sub-string in the check-in comment? I'd like to see the individual files in all the changesets in one view. In my case I am searching for all changesets that contain a defect number e.g. 'D-12345'.
I tried the example as outlined here. But running ...
tf history $/MyCodeRepo/Trunk -r /noprompt /format:detailed | ? { $_.comment -like *D-12345* }
... gives me several errors:
You must provide a value expression on the right-hand side of the
'-like' operator.
You must provide a value expression on the
right-hand side of the '*' operator.
Unexpected token 'D-12345*' in
expression or statement.
I then tried putting quotes around the search string but that just returned no results.
I have TFS power tools installed and I know you can use searchcs to search by Comment but you have to open each changeset individually.
Any ideas how I can do this?
Thanks,

Try with
tf history $/ -r | ? { $_.comment -like *D-12345* }
You can also try with fpt searchcs

Related

Get Changeset Id(s) from Merge

In TFVC you can merge changesets from Branch A into Branch B. Is it possible to view which changesets - specifically which ids - from Branch A were merged into Branch B?
You can use the following script :
$tfsUrl = "http://{Server}:{Port}/{Organization}/{Collection}"
$destinationBranchPath = "$/..."
$sourceBranchPath = "$/..."
# Change top with count of changesets you want to check
$body = 'repositoryId=&searchCriteria={"itemPath":"'+ $destinationBranchPath+'","itemVersion":"T","top":50}'
#Get top X changesets under destinationBranchPath
$changeSets = (Invoke-RestMethod -Method post "$tfsUrl/{Project}/_api/_versioncontrol/history?__v=5" -Body $body -UseDefaultCredentials).results
#Run over all changesets and check if sourceBranchPath is part of merage soruce path
foreach($changeSet in $changeSets)
{
$IsMerged = (Invoke-RestMethod -Method Get "$tfsUrl/_apis/tfvc/changesets/$($changeSet.changeList.changesetId)/changes" -UseDefaultCredentials).value.mergeSources.serverItem -like "*$sourceBranchPath*"
if($IsMerged)
{
#Print results
Write-Output $changeSet.changeList
}
}
Using the tf.exe command line tool, the merges command can provide the merge history between two branches.
So, in my example, from the source control root folder on my local machine I can run the following command in the shell of my choice tf vc merges a b /recursive to get a list of which changesets from a were included in merges to b:
Changeset Merged in Changeset Author Date
--------- ------------------- -------------------------------- ----------
20096 20292 Joey Bloggs 30/04/2018
20102 20292 Joey Bloggs 30/04/2018
20103 20292 Joey Bloggs 30/04/2018
Where the first column contains the changeset from branch a and the second column the changeset that merged it into branch b.
In order to get this working I had to add the folder location of tf.exe to my PATH variable.
Just adding another solution for anyone that don't want to use commands, but it will be a bit more time consuming if you want to know more than one merge
On TFS history of the merged branch, you can right click a changeset and choose Track Changeset option and then select the origin branch + merged branch in the next screen
https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/view-where-when-changesets-have-been-merged?view=azure-devops

TFS code search find <Button>

I want to find all usages of my react component in code.
I tried <Button> but Special chars <> are not supported.
Tried "Button" and i get "Button" and button with lowercase as results as well.
So exact match is also not supported.
Is there is a way to find a string exactly without any additional results?
Unfortunately, search symbols (<> and "" in your scenario) is not supported in code search.
In tfs the symbol "" is used for finding an exact match to a set of words by enclosing your search terms in double-quotes. For example, "Client not found".
Is there is a way to find a string exactly without any additional
results?
Yes, but it seems a little complex, just reference my answer in another thread:Is there a way to make TFS code search recognize the "#" symbol?
Checked for some characters in code search. You can't use the symbol
characters except * and ? as part of your search query, which
including below characters: . , : ; / \ ` ' " # = ! # $ & + ^ | ~ < >
( ) { } [ ]. The search will simply ignore these symbols.
But you can use wildcard characters * and ? to broaden your search.
You can use wildcard characters anywhere in your search string except
as a prefix in a simple search string or a query that uses a code type
filter. For example, you cannot use a search query such as
*RequestHandler or class:?RequestHandler. However, you can use prefix wildcards with the other search filter functions; for
example, the
search query strings file:*RequestHandler.cs and repo:?Handlers are
valid.
Please see Broaden your search with wildcards for details.
If you want to search the strings including these symbol exactly(such
as '#' here), you can code search with other strings (eg,
testexample.com here) to narrow down the scope first, then copy the
specific code to text editor which support the symbols (eg,
Notepad++), then search stings with the symbol characters.
Besides, if you are using Git, another workaround is using the code
search tool Hound: a lightning fast code search tool, it supports
the symbol characters. Reference this thread to use it:
How can I publish source code (Visual Studio) on a intranet?
Also, there is a User Voice here to suggest the feature, you can go and vote it up to achieve that in future.

powershell where-object specific number of numeric characters

I looked through some similar question but couldn't find an example of this sort of logic- what im looking for is a way to parse through a large return of usernames in powershell. User names that are not service accounts or kiosks have a specific naming convention of 6 grouped numeric characters: for example- username123456. I was thinking there has to be a way of using the where-object command but can't find anything on the syntax on technet or other PS resources. The one liner to get a return from the local domain is:
Search-ADAccount -PasswordNeverExpires | Select-Object Name, Enabled
This returns a list of domain accounts that have the password set to never expire. I want to only see the ones with the above naming convention ^^ I know you can achieve this with regex but my regex is quite rusty---if it can be done with where-object that would be optimal. I also looked into using pattern, but it seems to be for more complex returns than this... Thanks!
Are they under a specific OU? You could then use the -Searchbase parameter to limit the scope of the search to that OU.
Otherwise, Regex is probably going to be a good option to accomplish this.
Search-ADAccount -PasswordNeverExpires | Select-Object Name, Enabled | Where {
$_.name -match '\D\d{6}$'
}

Jira JQL can have inline/embedded comments?

I found a good list of tutorials about JQL, including a reference on how to write a plugin [1]. Is there already or would it be possible to add comments to a JQL query?
For example, to document my item, I'd like to be able to document that our sprint 'number' differs from the jira sprint 'id';
sprint = 777 (* Agile sprint #50 *)
//Update ; I notice that the Sprint ID is apparently not immediately created upon opening of a sprint. We just started a new sprint but there is no number for it, according to browsing the report page...
1.[] ; ; ; ; ; X.JQL recap! See everything in one post ; ; http://blogs.atlassian.com/2013/03/jql-recap/
Sorry, you can't.
If something is not here: https://confluence.atlassian.com/display/JIRA061/Advanced+Searching then you can't. (Except of course the custom JQL functions provided by plugins.)
I still wished for the answer to this old question, so I'll share what I finally came up with. This is a hack and not as pretty as I wish, but I add comments by adding a fake search. In the example below, before each complex set of terms, I add "SUMMARY !~ "♥♥ ".
SUMMARY !~ " ♥♥ No subtasks of stories in backlog: ♥♥ " AND issueFunction not in subtasksOf("type = story AND status = backlog") AND SUMMARY !~ " ♥♥ Filter for members of that team: ♥♥ " AND filter = 25233
or
SUMMARY !~ " ♥♥ No subtasks of stories in backlog: // " AND issueFunction not in subtasksOf("type = story AND status = backlog") AND SUMMARY !~ " \\ ♥♥ Filter for members of that team: ♥♥ // " AND filter = 25233 AND SUMMARY !~ " \\ ♥♥"
The !~ prevents the SUMMARY search from messing up your real JQL query. There is a chance that my comment could actually be found inside one of the results, so adding ♥♥ makes it highly unlikely. If your computer can't make that character (press Alt-3 and let go), using ** or other combinations may work for you.
I also like how the ♥♥ and the spaces to make the comment stand out, but perhaps there are better characters like ☻ or ♫ or -- or //. Sadly, [] and () are not allowed. Any spaces must be inside the quotes to be preserved when you save the query.
Sometimes I paste long queries into a programming tool like Notepad++ and make a User Defined Language to clarify the (sections). But note that the special characters don't transfer correctly.
That's the best I can come up with until this feature request is voted up enough and fulfilled:
https://jira.atlassian.com/browse/JRASERVER-20455

View all labels in Jenkins

Is there a easy way to get a list of all node labels in Jenkins?
I can see which labels are set on each node (.../computer/) and which nodes have the same label (.../label/). But similar to listing all nodes on .../computer/ there is no listing of all the labels on .../label/
The approach with python and jenkinsapi or similar seem a bit too advanced for a listing that probably already is available in Jenkins (but not visible?)
Haven't installed/tried it myself, but the "label linked jobs" jenkins plugin has a label dashboard as one of its features.. it sounds like this is what you're looking for
Just came across this question. Since I did not want to install a new plugin I tried to achieve the same using the script console.
You even have to possibility to filter-out labels. The following example will filter-out any node name from the list - which is considered a label, too, but probably not relevant to most users:
def allLabels = []
Jenkins.instance.nodes.each { node ->
node.assignedLabels.each { label ->
if (label as String != node.name) {
allLabels += label
}
}
}
println allLabels.unique().join('\n')
I use the Scriptler plugin with the "show labels overview" script that is available from the remote script catalogue. This draws an ascii art table of all nodes versus all labels and makes it easy to see at a glance all the labels that are defined and what nodes use them.
Similar like GBEE suggestion (scripts migth be similar):
Using the script consol of jenkins (Manage Jenkins > Script Consol) you can use groovy scripts too.
The script https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/show-labels-overview.groovy creates an ascii table of labels and agents.
Something like this:
|b|d|
|a|c|
| |e|
| |f|
------------------------------------------------------------------------------------------------------------------------
Agent_1 | | |
------------------------------------------------------------------------------------------------------------------------
abcd-agent |X| |
------------------------------------------------------------------------------------------------------------------------
abcd-agent2 | |X|
------------------------------------------------------------------------------------------------------------------------

Resources