In Azure DevOps Pipelines, "if expressions" and "conditions" are used to control the flow of the pipeline and determine when certain jobs, tasks, or steps should be executed.
"If expressions" are used to evaluate a condition and determine if a specific action should be taken. These expressions can include variables, functions, and operators. For example, the following if expression checks if the value of a variable called Build.SourceBranchName is equal to "master": AOMEI Partition Assistant License Key
condition: eq(variables['Build.SourceBranchName'], 'master')
The above expression will evaluate to true if the Build.SourceBranchName variable is equal to "master", and false otherwise.
"Conditions" are used to specify when a job or task should be executed. A condition is an expression that evaluates to a boolean value, where true means the job or task should be executed, and false means it should be skipped. For example, the following condition will only execute a job called "Build" if the branch being built is "master":
- job: Build
condition: eq(variables['Build.SourceBranchName'], 'master')
steps:
- script: echo "Building..."
In this example, if the branch being built is not "master", the "Build" job will be skipped and the pipeline will move on to the next job or step.
Both if expressions and conditions can be used to create more complex logic to control the flow of your pipeline. They can be used in a variety of contexts, such as in stages, jobs, tasks, and even individual steps.