From 3feb671cfa340fe3e22b9b7522ec0f2f65ac3cc2 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Sun, 29 Oct 2023 23:22:11 +0100 Subject: [PATCH] fix: azp: required number parameter (#251) * seen in the azure pipelines agent ci --- src/Sdk/AzurePipelines/AzureDevops.cs | 2 +- .../azpipelines/required-parameter-number/pipeline.yml | 4 ++++ testworkflows/azpipelines/required-parameter-number/tmpl.yml | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 testworkflows/azpipelines/required-parameter-number/pipeline.yml create mode 100644 testworkflows/azpipelines/required-parameter-number/tmpl.yml diff --git a/src/Sdk/AzurePipelines/AzureDevops.cs b/src/Sdk/AzurePipelines/AzureDevops.cs index 192aa8e8ddd..c063d82bc85 100644 --- a/src/Sdk/AzurePipelines/AzureDevops.cs +++ b/src/Sdk/AzurePipelines/AzureDevops.cs @@ -560,7 +560,7 @@ public static async Task ReadTemplate(Runner.Server.Azure.Devops.C templateContext.Error(sparameters, "A value for the 'name' parameter must be provided."); continue; } - var defCtxData = await ConvertValue(context, def, type, values); + var defCtxData = def == null ? null : await ConvertValue(context, def, type, values); if(cparameters?.TryGetValue(name, out var value) == true || def == null && (value = await (context.RequiredParametersProvider?.GetRequiredParameter(name) ?? Task.FromResult(null))) != null) { parametersData[name] = await ConvertValue(context, value, type, values); } else { diff --git a/testworkflows/azpipelines/required-parameter-number/pipeline.yml b/testworkflows/azpipelines/required-parameter-number/pipeline.yml new file mode 100644 index 00000000000..2484295d99d --- /dev/null +++ b/testworkflows/azpipelines/required-parameter-number/pipeline.yml @@ -0,0 +1,4 @@ +steps: +- template: tmpl.yml + parameters: + no: 42 diff --git a/testworkflows/azpipelines/required-parameter-number/tmpl.yml b/testworkflows/azpipelines/required-parameter-number/tmpl.yml new file mode 100644 index 00000000000..8d0b9a2507f --- /dev/null +++ b/testworkflows/azpipelines/required-parameter-number/tmpl.yml @@ -0,0 +1,5 @@ +parameters: + - name: no + type: number +steps: + - script: echo ok