Azure DevOps Access Custom Field From Script - variables

I have a required custom field on any ticket created (Bug, Tasks, PBI).
I have a pipeline that creates tickets automatically, but the values that are used to create these tickets doesn't have a value for my custom field. I want to set this custom field by adding an entry to the pipeline variables, but I don't know the variable name of the custom field.
How can I find the variable name of the custom field so I can access it?

I found out how to determine your custom variable name.
ADO has a bunch of APIs. The following will give you all the details of a specific work type. For my case I needed the "bug" work type.
/*
Api to display work type fields in JSON format
Replace {} with correct values
*/
https://dev.azure.com/{orginization}/{project}/_apis/wit/workitemtypes/{type}/fields?api-version=6.0
The resulting JSON will give you a whole list of variables. Here is what the System Variable and a Custom Variable look like.
The referenceName is the variable name you would use in your scripts, etc.
TL;DR -
Take your field name and remove all spacing and then put Custom. in front of it.
Custom.FieldNameWithNoSpace

Related

Can we have a dynamic string input with as a variable present on the terraform resource block?

Scenario: to have multiple Kubernetes deployments I have a skeleton.tf file that could create an app as per requirement with minimum variable changes and in different namespaces and I do not want to provide a default name so that I will give the input everytime I do a Terraform plan and apply
like
resource "kubernetes_deployment" "${var.deployment-1}" {
...
...
namespace= var.namespace_1
...
}
how do I achieve this? Is this supported, because I face a syntax interpolation error,
or
Invalid string literal: Template sequences are not allowed in this string. To include a literal "$", double it (as "$$") to escape it.
or
Invalid character: This character is not used within the language.
or
Invalid block definition: Either a quoted string block label or an opening brace ("{") is expected here.
I have read about the terraform workspaces but then, it would be a tedious task to be able to get the resource name as a dynamic input. any help or workarounds to this is appreciated.
The name given in the second label of a resource block is used only within the current Terraform module, so there is no need for it to be dynamically customizable. If you don't have a specific name to use then you can use a generic name like "main".
Because this is a Terraform-only name, Terraform will automatically deal with it appearing in possibly several different instances of your module, because the full address of a resource includes the address of the module that contains it. The whole result is therefore unique with in a Terraform configuration, and the resource's local name is unique within the module that declares it.

Show all variables and their values in VBA during runtime

In my current project in Access VBA, I created a window which works like a console and now I am trying to add a possibility to display any public variable. It should work like:
Show_var [variable_name]
So it should be like in the direct window where i can type:
? pVar.variable_A
I found out that using
Application.VBE.ActiveVBProject.VBComponents(11).CodeModule.CountOfLines
I can display the number of lines within a module or form so I thought perhaps I could somehow find the variables there, cycle through them and when the correct one is found, its value can be shown. OFC I could make a Select Case Statement where all variables are included but that is not the way I want to do it because it is complicated and must be changed every time update my public variable list.
There are so many problems that I think you are out of luck. Let me just list some of them:
There is no way to get a list of all variables - that would mean you would need access to the internal symbol table.
As a consequence, you would have to read the code (CodeModule lets you read the code of a module), and write an own parser to fetch all declarations (hopefully you use Option Explicit)
AFAIK, the is no method that can access the content of a variable via it's name.
Even if there would be any such method: What would you do with different data types, arrays and especially with objects.
If a user runs into problems, often it is a runtime error. If you don't handle that errors with some kind of error handler, the only option if a user cannot enter the debugger is to press "End" - which would destroy the content of all variables.
You have to deal with scope of variables, you can have several variables with the same name and you will likely have lots of variables that are out of scope in the moment you want to dump them.

How to user user input variables in Build file?

prompted for user entry by I'm new to ant and I was wondering if it would be possible to create a global variable in the build file so that I can use it repeatedly throughout the file itself.
For example, if the command were 'ant a', I would be able to use that value 'a' throughout the build file (for example in a file path i.e C:/test/a).
The reason I want to know how to do this is because there are multiple values like 'a' (lets say all the letters in the alphabet), and instead of copying and pasting the same code 26 times, I would be able to have 1 piece of code that takes different values (depending on what the user enters). In java you are able to have a variable storing the user input, and use that variable throughout the code (same idea here).
I tried searching for this but wasn't sure how to word it.
UPDATE
With the help of some people I managed to solve what I needed.
So I managed to use Input Task to kind of fix my problem. I prompted the user for an entry by using the following command:
Then I can just use the value entered by the user anywhere i want by simply writing ${hold.it}. For example in a file path "C:/go/to/${hold.it}"
Have a look at Ant properties and the property task used to set them. For example, you can define a property named prop1 and pass its value using ant -Dprop1=some_value.
A property is "global" since after defining it, any part of the buildfile can use it.

How to use variable value in live templates in Intellij IDEA?

I want to create live template for setter.
I've created this template
How can I use value of par variable to generate value of var variable? Basically, I want to avoid redundancy here and put name of variable only once and other one will be generated automatically by some algorithm.
UPDATE
I want to clarify a little bit what I want to achieve.
Suppose I want to create setter with name setTime which has parameter time.
public void setTime(long time)
{
// ...
}
I don't want to type "time" twice - capitalized and non-capitalized. I want to type just parameter name so method name will be generated automatically.
UPDATE (Answer)
Turned out that variable order is important. This is final result of what I want
You can use the soutv as an example, notice how it defines a copy of a variable:
It's also possible to define custom expression for live templates via plugins or Groovy code:
How can i add custom expression functions for Live templates in Intellij.

How do I use Team Build Properties in MSBuild?

I have a simple tfs-2010 build definition using the default process template. In it I defined the Build Number Format using $(BuildID) to define part of the computed field. This works and I can see what BuildID's value is.
Now I try to pass the BuildID property to MSBuild as an argument:
/p:SomeProperty=$(BuildID)
However when I look at the build log I see SomeProperty literally equals $(BuildID) rather then the value of BuildID.
What am I missing?
Update for clarity: What I'm asking is how to reference as a Build Process Parameter in the Build Definition. For example Build Number Format has a default expression of $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)
You need to use a VB.NET expression. For example:
String.Format("/p:SomeProperty={0}", BuildDetail.BuildNumber)
The Build Number tokens, e.g. $(BuildDefinitionName), are specific to the Build Number Format process parameter. They aren't tokens that you can use anywhere else in the build process. Most are available in the BuildDetail object or from the environment. The Build Id is a bit of a special case, however. It comes from the identity column of the builds table and isn't directly exposed in our public API. You could extract it from the BuildNumber, like this:
BuildDetail.BuildNumber.Substring(BuildDetail.BuildNumber.LastIndexOf('/') + 1)
Note that you would need to do this in the XAML directly rather than putting a VB expression into the build process parameter editor GUI. That's because those values just get passed through as literal strings.