-
Couldn't load subscription status.
- Fork 61
Description
Steps to reproduce the issue
- Don't pass
versionsRepoReftoeng/common/templates/stages/dotnet/build-and-test.ymland passnoCache: true - Try to queue a build-and-test build.
Expected behavior
The template should detect no cache, so the build successfully doesn't try to clone any versions repo.
Actual behavior
A queue-time error:
Checkout of repository 'null' is not supported. Only 'self', 'none', or a repository alias are supported.
Checkout of repository 'null' is not supported. Only 'self', 'none', or a repository alias are supported.
This happens in eng/common/templates/steps/init-matrix-build-publish.yml. Naturally, AzDO doesn't say that, but deleting the step does let the build queue successfully.
Additional information (e.g. issue happens only occasionally)
I thought I'd try using eng/common/templates/stages/dotnet/build-and-test.yml for Go because it looks general enough now. I haven't tried beyond this issue yet--figured I'd write this up first.
I think the issue is AzDO yaml and types, interacting badly in potentially a few places.
First, when I pass in noCache: true, based on earlier experiments, I believe AzDO is coercing the type to a string to fit into dotnet/build-and-test.yml's "dynamic" parameters (rather than type-safe parameters). So: in the context of this template, noCache should have the string True.
This condition then misfires because of the type:
# Only clone versions repo if we need to reference it during the build in order to cache images.
${{ if eq(parameters.noCache, false) }}:
versionsRepoRef: ${{ parameters.versionsRepoRef }}Any string that isn't '' is coerced to True when converted to a boolean, so this seems to end up being:
versionsRepoRef: null
I can't quite convince myself of a good reason that ends up causing Checkout of repository 'null' is not supported.. It passes through a few more templates before it's actually used. But a few changes each make it work (allow the build to queue), in isolation, which led me here:
- Change to
versionsRepoRef: ""in the default parameter list. - Delete
${{ if eq(parameters.noCache, false) }}: versionsRepoRef: ${{ parameters.versionsRepoRef }}entirely. - Delete the
checkoutstep entirely (to reflect the state it should be in). - Replace the
checkoutstep with apwshscript that showsconvertToJson(parameters).{ "publishConfig": "null", "versionsRepoRef": "null", "versionsRepoPath": "versions" }- https://dev.azure.com/dnceng-public/public/_build/results?buildId=1140563&view=results
- https://dev.azure.com/dnceng-public/public/_apis/build/builds/1140563/logs?logid=1
All new templates I write use typed parameters, and it seems to help a lot with avoiding stuff like this. Type coercion can still be an issue, but at least the parameter declarations make it explicit.
The inability to pass "extra" parameters in this "parameter mode" was challenging at first (and the verbosity of specifying a lot of passthrough parameters is extreme), until I realized that I could make an object-typed parameter to capture more dynamic params. With that sorted out, the fact that AzDO fails when some parameter was passed but not expected actually becomes nice compile-time assistance. Touched on it in #1771 (comment) but seems worth mentioning in this context too.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status