Hello @Divakaran, D (Dipu) ,
The issue is that startswith(parameters.coreSDKVersion, '8.')
checks for an exact match at the beginning of the string. If the value is set as '8.x'
, '8.0'
, or has extra spaces, the condition doesn't match, and the pipeline skips the expected steps. Azure DevOps evaluates conditions at compile time, and if the parameter isn't set correctly in the parent template, it falls back to the default value '6.x'
, leading to issue. So, try using contains()
instead of startswith()
. It will check that any version containing '8'
It get recognized, Check this corrected condition:
- ${{ if and(eq(parameters.buildType, 'api'), contains(parameters.coreSDKVersion, '8')) }}:
- template: task-netcore-net8-api-swagger-publish.yml
parameters:
artifactStagingDirectory: '{{ parameters.artifactStagingDirectory }}'
swaggerDoc: '{{ parameters.swaggerDoc }}'
startUpAssembly: '{{ parameters.startUpAssembly }}'
To confirm that the correct value is being passed, add a debug step to print coreSDKVersion
:
- script: echo "coreSDKVersion: $(coreSDKVersion)"
displayName: "Debug: Print coreSDKVersion"
This will show the value in the logs, making it easier to verify what’s being used in the condition.
This all things follows Azure DevOps documentation on YAML expressions and template conditions. You can check the official docs on expressions and template expressions for more details.
Hope it helps!
Please do not forget to click "Accept the answer” and Yes
wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.