Litium-storefront-cli import definition pipeline issues

I’m trying to set up a CI/CD pipeline for the React Accelerator and it seems like I’ve run into some issues automating the the deploy of the litium definitions

2023-12-15T12:53:15.7704015Z Unhandled exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
2023-12-15T12:53:15.7704764Z    at System.ConsolePal.ReadKey(Boolean intercept)
2023-12-15T12:53:15.7705457Z    at Litium.Storefront.Cli.Templates.TemplateCommandParser.<ReadUsernameAndPassword>g__ReadPasswordFromConsole|10_1() in /_/src/Storefront.Proxy/Templates/TemplateCommandParser.cs:line 106
2023-12-15T12:53:15.7706009Z    at Litium.Storefront.Cli.Templates.TemplateCommandParser.ReadUsernameAndPassword(InvocationContext context) in /_/src/Storefront.Proxy/Templates/TemplateCommandParser.cs:line 69
2023-12-15T12:53:15.7706666Z    at Litium.Storefront.Cli.Templates.TemplateCommandParser.GetHttpClient(InvocationContext context) in /_/src/Storefront.Proxy/Templates/TemplateCommandParser.cs:line 149
2023-12-15T12:53:15.7707747Z    at Litium.Storefront.Cli.Templates.TemplateImportCommand.ExecuteAsync() in /_/src/Storefront.Proxy/Templates/TemplateImportCommand.cs:line 24
2023-12-15T12:53:15.7708329Z    at CommandExtensions.<>c__DisplayClass0_0.<<SetHandler>b__0>d.MoveNext() in /_/src/Storefront.Proxy/CommandLineParsing/CommandExtensions.cs:line 10
2023-12-15T12:53:15.7708746Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7709194Z    at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
2023-12-15T12:53:15.7709549Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7709923Z    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
2023-12-15T12:53:15.7710289Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7710614Z    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
2023-12-15T12:53:15.7710950Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7711506Z    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
2023-12-15T12:53:15.7712221Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7712631Z    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
2023-12-15T12:53:15.7714688Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7716654Z    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
2023-12-15T12:53:15.7716904Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7717427Z    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
2023-12-15T12:53:15.7717656Z --- End of stack trace from previous location ---
2023-12-15T12:53:15.7717914Z    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()

Pipeline Powershell script to recreate the issue:

[CmdletBinding()]
param (
    [Parameter(Mandatory, HelpMessage = "The root Litium definitions directory")]
    [string]$litiumDefinitionsPath,
    [Parameter(HelpMessage = "Address to the Litium backend")]
    [string]$litiumUrl=$env:LitiumBackendUrl,
    [Parameter(HelpMessage = "Litium backend username")]
    [string]$litiumUsername=$env:LitiumBackendUsername,
    [Parameter(HelpMessage = "Litium backend password")]
    [string]$litiumPassword=$env:LitiumBackendPassword
)

write-host "litiumDefinitionsPath: $($litiumDefinitionsPath)"
write-host "litiumUrl: $($litiumUrl)"

litium-storefront definition import --file "$($litiumDefinitionsPath)/**/*.yaml" --litium $litiumUrl --litium-username $litiumUsername --litium-password $litiumPassword

Any tips or is this something you can fix?

1 Like

I got an answer through email regarding this issue and the issue was quite simple once explained - The variable $env:LitiumBackendPassword was empty because the password was set as a secret in the pipeline.

While the error message could have been a bit better it makes sense for it to ask for a password when its not provided.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.