I have a question and I don't find anything about it in microsoft documents.
I use this agentles job:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/http-rest-api?view=azure-devops
I couldn't find how I can use the output variables of this task without using any code / script for use in another task.
Any help / document would be appreciated.
I think it is impossible.
The task uses agentless job but that job could not support environment variable. And Invoke REST API task did not have the option to output the result variable.
One alternative approach is that you could use agent job with a powershell task(that could invoke rest api) and then use custom variable to get that output variables.
Otherwise, there is no function to realize that.
Related
Are there any widely accepted methods for an *.exe to detect if it's running as part of an ADO pipeline?
The script will be running both as part of a pipeline and on workstations and should be able to determine with very high confidence where it is running, if possible.
Eg. any pre-defined variables that are meant for this (could not find) or some other pre-defined value that can be inspected?
There is a whole number of predefined variables, most of which you could use, I would say. However, there is one which sounds like what you are looking for:
TF_BUILD
Set to True if the script is being run by a build task.
This variable is agent-scoped, and can be used as an environment variable in a script and as a parameter in a build task, but not as part of the build number or as a version control tag.
I'm trying to debug my first Bicep template.
How can I just write a variable or parameter value to standard output?
Something like:
var hello = 'hello world!'
write-host(hello)
The best is to use module outputs which you can read from Portal. Module deployments are separate deployments visible in the "Deployments" section of resource group / subscription / etc. Even if the top-level deployment will fail, outputs from modules inside that were successful can be read, alongside parameters they took.
Remember, that bicep is a declarative language, not imperative, so the file is not being processed sequentially.
I created some simple hello world type templates early on in Bicep's history for this type of question https://github.com/Azure/bicep/tree/main/src/Bicep.Core.Samples/Files/user_submitted/000/01-hello-world .
The've been moved around and are harder to find, but still helpful.
I'm trying to set up a variable in the Azure Build Pipelines Classic Editor to use conditional functions to determine its value. YAML is not an option (unless there's some way to inject YAML as part of a Classic build...?).
In my current scenario, the idea is that the variable would return one of a few possible string values (or empty string) depending on the branch that triggered the build.
I want something along the lines of this:
I fear this may be a YAML-only thing, but hopefully someone can tell me I'm wrong about that.
Like Matt mentioned in the comment, the best approach for this would be to use a script (powershell or bash) that will have the logic to set the variable.
For more details about how to set a variable, have a look at this documentation.
I am creating a build pipeline (YAML) with some "Powershell" task in it in which all are not inline scripts. I need to have a PSCustomObject that can be passed as a global variable (this param should be accessible across the pipeline). For example, it needs to be used like this. $myPSObject.value1 in first task, $myPSObject.value2 in second task etc. Is it possible?
Any leads would be much appreciated.
No, this is definitely not possible, what you can do, however, is cast it to json (compressed would, probably, make more sense) and then in your steps read it and cast it back to an object and work with it like you normally would. You'd need to use azure devops build variable for that, not powershell variable
I need to update an Nant script automatically by fetching some data from database. The solution I can think of is to be done through a service which fetches the data from DB and update the Nant script.
Can this be done? If yes, how?
In theory, if you need to change how the script works then you could create a program to generate the NAnt build file, run it with the exec task, include that file and then call a target.
That seems a bit over-complicated though. I suppose it depends on how much the script will change based on the data.
If the data is simply configuration, then you can use the data to set properties in your build script (either by the same mechanism above, or by creating a custom task to create a property value based on the result of a SQL statement). Then use those properties to determine control flow in the build script using standard things like if statements and foreach loops.
I don't think that there's anything built-in that will do this for you, but custom tasks are very easy to create if you can program.
If you update/edit a nant script it does not change the current execution. Instead you can generate .build files and execute them via <nant> task, for example using a <foreach> loop or <style> xsl-transformation. An alternative would be to write a small <script>, in particular if you can program it comfortably in C#. If you wish more specific answers more information would be helpful. (database used, what tools you can use to extract data)