Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azp: fix variable override in nested scopes #541

Merged
merged 2 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Sdk/AzurePipelines/AzureDevops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,12 +1452,12 @@ public static async Task<MappingToken> ReadTemplate(Runner.Server.Azure.Devops.C
if(kv.Value.IsGroup || kv.Value.IsGroupMember) {
continue;
}
vars.Add(kv.Key, new StringContextData(kv.Value.Value));
vars[kv.Key] = new StringContextData(kv.Value.Value);
}
}
else
{
vars.Add(name, new StringContextData(value));
vars[name] = new StringContextData(value);
}
};
if(strictParametersCheck) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private async Task HandleMappingWithAllLooseProperties(
var nextValue = await Evaluate(valueDefinition);

if(mappingDefinition.Get<MappingDefinition>().First().AzureVariableBlock && m_context.ExpressionValues?.TryGetValue("variables", out var varsRaw) == true && varsRaw is DictionaryContextData vars) {
vars.Add(nextKey.ToString(), new StringContextData(nextValue.ToString()));
vars[nextKey.ToString()] = new StringContextData(nextValue.ToString());
}
mapping.Add(nextKey, nextValue);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variables:
test: val0
jobs:
- job: job1
variables:
test: val1
steps:
- ${{ if ne(variables['test'], 'val1') }}:
- assert: failure
- bash: echo $(test)
- job: job2
variables:
- name: test
value: val2
steps:
- ${{ if ne(variables['test'], 'val2') }}:
- assert: failure
- bash: echo $(test)
- job: job3
steps:
- ${{ if ne(variables['test'], 'val0') }}:
- assert: failure
- bash: echo $(test)
Loading