rsconnect deployment hooks guidance

I am interested in using rsconnect.pre.deploy and rsconnect.post.deploy options in rsconnect.

FIrst, I am considering using the rsconnect.pre.deploy function to perform a "pre-flight" check on the app. Is this consistent with its purpose? Specifically, if a pre-flight requirement fails, is there a way to safely halt a deployment (e.g. by using stopifnot to test the requirement)?

Second, the hooks seem to have limited knowledge of its execution context. I understand from reading rsconnectOptions documentation and the source code that functions named by these options are called with a single argument, being the appDir.

I would like my rsconnect.post.deploy hook function to somehow determine more of the execution context, specifically the path to the deployment record (.dcf) file.

Is this possible somehow?

FWIW: Posit Support agreed with the desirability of my use case, advising me as follows:

It would be nice for the hook function to be able to accept more information from the deployment command. I would definitely bring this up as an issue/feature request with the rsconnect package at Issues · rstudio/rsconnect · GitHub. That is where you will be able to specify exactly what you'd like to see for this feature and make a case for it. I think the hardest part with this would just be documenting exactly what variables get past through and making the change backward compatible with current versions of the package.

Accordingly, I have raised this issue here.

1 Like