Azure DevOps Build Pipeline Code Version/Merged Changesets - azure-devops

I have scheduled build pipeline thats autmatically triggered by changes in source code. Basically I want to know which changesets got into build before pipeline started to execute.

You can use the predefined variable $(Build.SourceVersion) to get the changeset that triggering your pipeline. For detailed information, please refer to this document.
You can use this variable as part of the pipeline definition or value in the script that you want to run in pipeline. When the pipeline is triggered, this variable will be assigned by the system automatically.

Related

How to specify build variables from a particular artifact?

I am trying to use Predefined Build Variables in my Release Pipeline with CI Trigger enabled. My release pipeline has multiple Artifacts coming in from Multiple separate Build Pipelines.
When I use the variable $(Build.BuildNumber), it targets the variable to a specific artifact all the time. I would really like it to use the one from the Build Pipeline that is triggering the deployment. But if that is not possible, can I at least specify which Artifact-set it should use the Build variables from?
You would probably do this with a combination of information. You would first need to get the trigger artifact alias using a pre-defined release variable: Release.TriggeringArtifact.Alias
Then you want to pull details about a specific artifacts build number, you can reference it using a pre-defined release variable (replacing with the alias from the first variable): Release.Artifacts.{alias}.BuildNumber
The build number or the commit identifier.
Azure Pipelines example: 20170112.1
Jenkins/TeamCity example: 20170112.1
TFVC example: Changeset 3 Git example: 38629c964
GitHub example: 38629c964

How can you see a variables snapshot of an azure yaml pipeline run?

For a classic release pipeline, in Azure Devops you can easily see a snapshot of the variables and values for each pipeline run. How can you see this if you use a multi stage full yaml pipeline?
As a workaround I specificall added a custom task (ShaykiAbramczyk.printAllVariables.printAllVariables.printAllVariables#1) to print out the variables. This way you can see a Print Variable task on your runs. It will not print secrets as expected. This does the job, least until Devops team implementes this feature.
If you want to see the snapshot of the variables defined in yaml file of pipeline run. You can check the yaml file of the commit that related to the pipeline run as Daniel mentioned.
If you have variables defined in the Variables tab in the pipeline UI page. You can see the variables snapshot from the History tab.
click the 3 dots of the yaml pipeline edit page and choose Triggers

How to pass Variable value between two yaml pipeline in azure

I have two pipelines one is primary which triggers the other. How to pass a variable set on the first pipeline to second triggered one.
Example:
Variable-Name: Validate = True
I want to pass the validate variable to secondary triggered pipeline . I could not find any documentation that would help.
You could store the necessary value to a file, then include this file in current build's artifact (Publish pipeline artifact task).
Then in secondly pipeline, you could add Download Pipeline Artifacts task to download latest artifact of first build and read the content of necessary file.
If you are using pipeline resource (could enable trigger), please add Download task to download artifact of that pipeline resource.
Resources: pipelines

How to pass "settable at queue time" variable value from build pipeline to release pipeline

I have two pipelines on azure devops that do the following:
BUILD PIPELINE
Asks the user for the desire branch name and ticket id (from our ticketing system). Using two "settable at queue time" variables.
Gets the files from the specified branch name, builds the project and generate the artifacts that are later use by the RELEASE pipeline
RELEASE PIPELINE
This release pipeline is being triggered by the completion of the BUILD pipeline specified before. This pipeline completes the following tasks:
Creates new app service slot using an Azure CLI command task. In this task I need the ticket id, in order to create the slot with the corresponding ticket id as its name
Deploy the application to the created app service slot
I haven't found a way to pass to the RELEASE pipeline the ticket id the user entered when running the BUILD pipeline that triggered this RELEASE.
Unfortunately, there's no such a build-in function in Azure DevOps. While thanks to Martin Hinshelwood, we had an extension- Variable Tools for Azure DevOps Services to achieve the goal.
As you can see in the extension's doc, add a Variable Save Task in your build pipeline and a Variable Load Task in your release pipeline. After these two tasks, the variables are fully passed to your release.
Check below as reference:

In Azure DevOps how can I configure my pipeline so that I could easily trigger it for the source code in a different branch?

We often want to test the first part of our release pipeline using a code from the branch. While I can easily trigger the build from any branch, not so with the release pipeline - I have no idea how to trigger it from anything else other than the branch specified in it.
So far my solution was to temporary clone the pipeline, redirect to another branch and use it while testing. Then delete it.
But I wonder if there is a better way. We use TFS 2018 (on-premises), so no YAML to show here.
This is how our pipeline looks like:
When I click the Source I get:
And the Continuous Deployment Trigger on the Source:
Now clicking the Build Artifact:
And the CD trigger:
The four smoketest5x are the same. They have two tasks (a ps1 script and to publish the test results) and their triggers are:
Pre-Deployment:
Post-Deployment:
Finally, the Production stage. Its pre-deployment trigger is the most interesting:
And there is manual approval.
It does not seem possible to provide the branch at release creation time, but maybe I am missing something here?
You can't specify a branch at release time. If you need to do that, create a build pipeline that publishes an artifact, then release a build. You can choose builds versions at deployment time.