In my use of Chocolatey to provision Jenkins build nodes, I have a need to perform certain operations before and/or after a choco upgrade
(e.g., stopping the Jenkins service, or reconfiguring Git after installation).
My simplest alternative is to always do these operations regardless of whether an upgrade actually is available/was installed, but ideally I would only do them if it is. I see choco upgrade <pkg> --whatif
as a way to detect a single outdated package, but short of parsing the output (e.g., looking for the string "is available"), there doesn't look like a simple way to programmatically detect the result. For example, the %ERRORLEVEL%
after running this command is 0 regardless of whether an upgrade is available.
Is there a better alternative to parsing the output as suggested above, given my scenario?