Ortus-Solutions / docker-commandbox

Official CommandBox Docker Image for ColdFusion/CFML/Java applications
62 stars 41 forks source link

Throw error when cfpm fails to install adobe packages #80

Closed ghidinelli closed 7 months ago

ghidinelli commented 9 months ago

When building images using commandbox, cfpm is run to install Adobe dependencies. On occasion, those fail to be downloaded and install but the build continues as though everything is OK but results in an invalid image that fails (in our case, today, in our pipeline and took down prod).

Is there a way to handle a cfpm exit code and abort the build if it does not complete successfully?

iwburns commented 9 months ago

For some additional context on this, here are some of the messages we see in our build step when this happens:

The packages repository https://www.adobe.com/go/coldfusion-packages is not accessible. You can only load the packages that are available locally in the /usr/local/lib/serverHome/WEB-INF/bundles directory. [...] An error has occurred while installing the package caching. Exception : null caching package is uninstalled successfully. [...] An error has occurred while installing the package document. Exception : null document package is uninstalled successfully. [...] An error has occurred while installing the package image. Exception : null image package is uninstalled successfully. [...] The package document is not found in the repository. An error has occurred while installing the package pdf. Exception : The package document is not found in the repository. pdf package is uninstalled successfully. [...] An error has occurred while installing the package chart. Exception : null chart package is uninstalled successfully. [...] An error has occurred while installing the package debugger. Exception : null debugger package is uninstalled successfully. [...] An error has occurred while installing the package mail. Exception : null mail package is uninstalled successfully. [...] An error has occurred while installing the package eventgateways. Exception : null eventgateways package is uninstalled successfully. [...] An error has occurred while installing the package scheduler. Exception : null scheduler package is uninstalled successfully. [...] An error has occurred while installing the package zip. Exception : null zip package is uninstalled successfully. [...] An error has occurred while installing the package postgresql. Exception : null postgresql package is uninstalled successfully.

EDIT: I should have included this earlier. Here's the command we're running: box cfpm install postgresql,zip,scheduler,image,pdf,eventgateways,mail,debugger,adminapi,document,caching,chart

jclausen commented 7 months ago

I would have to defer to @bdw429s to see if there is a way to get the cfpm command in CommandBox to exit non-zero. If not, this would need to be filed as an issue there.

bdw429s commented 7 months ago

The cfpm command in CommandBox defers to the run command, which throws an error for a non-zero exit code. So I'm assuming cfpm itself is not returning a non-zero exit code. I suppose we could inspect the console output for the word "error".

I'd test what exit code cfpm returns, but I'm not sure how to force an error like you showed above. I did test and confirm that when you try to install a package name that's not found, cfpm does NOT return a failing exit code, but instead a "successful" one:

C:\Users\brad>"C:\Users\brad\.CommandBox\server\544A7B679E94B85EF707D2BA1E07DF35-testadobe\adobe-2023.0.7.330663\WEB-INF/cfusion/bin/cfpm.bat" install foo
The package foo is not found in the repository.
C:\Users\brad>echo %errorlevel%
0

If cfpm doesn't return a failing exit code, the ticket should really be logged with Adobe :)

jclausen commented 7 months ago

I’m going to close this one out then, as once Adobe returns a non-zero for a failure, then CommandBox and all containers built with it will as well