Use expressions instead of variables in azure devops - variables

In azure devops, inside the classic build, I can generally do $(myVar) to get the value of a variable in certain places. I am not sure if that particular usage has a name.
Is there a way to pass an expression for the same use cases. I mean instead of $(myVar) can I do something like $(coalesce(myVar, otherVar))?
I have tried wrapping it in different brackets, doesn't seem to work.
I have checked the docs here: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops
It doesn't show how to use in the classic pipelines, only yaml.

Is there a way to pass an expression for the same use cases. I mean instead of $(myVar) can I do something like $(coalesce(myVar,
otherVar))?
Agree with Daniel, the common use of Expressions is to define conditions for a step, job, or stage or define variables. The expressions work well in Yaml pipelines while it's not supported in Classic pipelines if you want to define variables using $(coalesce(myVar, otherVar)) instead of $(myVar).
The $(coalesce(...))is one of the built-in functions. The only working scope of those functions in classic pipelines is conditions for Job/Task, see:
Job:
Task:
But it seems you're trying to use built-in functions when defining variables, for now that's not supported in classic pipelines. Those can only be used to define/control the conditions for job/task in classic pipelines.

Expressions as outlined in the documentation you linked only apply to YAML. You won't be able to do what you want to do unless you use YAML.

While using expressions in classic pipelines is not supported (except in the control section of the task), I've had success defining a release variable with the expression, and using that release variable instead.
In my case I wanted to do releases based on git tags, and extract the version number from the tag.
Variable definition (with the expression I want to use):
Using the variable in the task:

Related

MuleSoft runtime property

The current version of mule runtime we are using is 4.3.0. We have multiple environments where we have to set up the runtimes.
We want to define a variable in the runtime wrapper.conf and use that variable across multiple properties.
Tried to follow the tanukui software instructions "https://wrapper.tanukisoftware.com/doc/english/props-envvars.html"
set.default.ENV_BASE_PATH=/path/to/the/environment
wrapper.java.additional.22=-DMULE_LOG_DOMAIN_V2=%ENV_BASE_PATH%/logs/%WRAPPER_HOSTNAME%/DomainV2
WRAPPER_HOSTNAME is working which is a default variable that tanuki provides. But the custom variable "ENV_BASE_PATH" is not working.
when the runtime is comes up it is not taking "ENV_BASE_PATH" as a variable but taking it as an absolute value.
My recommendation is to just avoid using environment variables in the wrapper. Just replace it by the actual value. It doesn't look as good but it will work.

Can we do variable substitution on YAML files in IntelliJ?

I am using IntelliJ to develop Java applications which uses YAML files for the app properties. These YAML files have some placeholder/template params like:
credentials:
clientId: ${client.id}
secretKey: ${secret.key}
My CI/CD pipeline takes care of substituting the actual value for these params (client.id and secret.key) based on the environment on which it is getting deployed.
I'm looking for something similar in IntelliJ. Something like, I configure some static/fixed values for the params (Ex: client.id and secret.key) within the IDE and when I run locally using the IDE, these values should be substituted onto these YAML files and run.
This will actually save me from updating the YAML files with the placeholder params each time I check in some other changes to my version control system.
There is no such feature in IDEA, because IDEA cannot auto detect every possible known or unknown expression language or template macros that you could use in a yaml file. Furthermore, IDEA must create a context for that or these template files.
For IDEA it's just a normal yaml file.
IDEA has a language injection feature.
That can be used to inject sql into a java string for instance or inject any language into a yaml field.
This is a really nice feature and can help you to rename sql column names aso. but this won't solve your special problem, because you want to make that template "runnable" within in certain context where you define your variables.
My suggestion would be, to write a small simple program that makes nearly the same as the template engine does.
When you only need simple string replacements and no macro execution then this could be done via regular expression.
If it's more complicated I would use the same template engine as the "real processor" does.
If you want further help, it would be good to know how your yaml processing pipeline looks like.

Tool to Identifying Global Variables in VB.NET

Is there an automated tool for VB.Net that will identify all global variables in a project?
Short of that, is there any scripts that can be used that will facilitate a manual review of global variables?
There seems to be tools for C/C++, but not for VB.Net:
Tools to find global/static variables in C codebase
Is there a tool to list global variables used and output by a C function?
EDIT:
My current approach uses the following VS REGEX searches:
For finding global variables:
~(Private:b+)Shared:b+:i:b+As:b+
For finding global properties:
~(Private:b+)Shared:b+(~(ReadOnly:b+):i:b+)#Property:b+:i([(][)]|[]):b+As:b+
fxCop might help, but you might need to write a plugin for that particular function.
Also, ndepend (Using the CQL "code query langauge") I'm pretty sure will give you a report or globals (and a whole lot more).
What are you calling a "global variable"? a variable defined as Shared (private or otherwise) isn't 'global' at all.
Really, the only 'global' variables left in vb.net are declared as public in a module

writing custom functions that use external java classes on Hive

I've been thinking of how to do it in Hive.
For e.g. i've a specific field in a log file that I want to extract (this is already possible in Hive) and then I want to map this field's value to something else. This mapping is determiened by own customic business logic that is coded up in a Java Class.
How can I use this Java class in Hive?
You should follow the instructions here: UDF Information to create a User Defined Function which can be called like substr, count or length.
You will need to use
add jar myjar.jar;
in the hive script, just as you had done with the jar containing the UDF. I would recommend packaging them all up in a single jar.

How to determine where, or if, a variable is used in an SSIS package

I've inherited a collection of largely undocumented ssis packages. The entry point package (ie: the one that forks off in a variety of directions to call other packages) defines a number of variables. I would like to know how these variables are being used, but there doesn't seem to be an equivalent of "right click/Find All References"
Is there a reliable way to determine where these variables are being used?
A hackish way would be to open the dtsx file in a text editor/xml viewer and search for the variable name.
If it's being used in expressions, it should show it and you can trace the xml tree back up until you find the object it's being used on.
You can use the bids helper add-in thats gives you visual feedback on where variables are used in your package. Thats makes it very fast and easy to detect them.Besides that, it offers several other valueable features.
Check out: http://bidshelper.codeplex.com/