Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-deploy and post-deploy commands + context + runOnlyOnceByOrg #466

Closed
nvuillam opened this issue Nov 5, 2023 · 13 comments · Fixed by #770
Closed

pre-deploy and post-deploy commands + context + runOnlyOnceByOrg #466

nvuillam opened this issue Nov 5, 2023 · 13 comments · Fixed by #770
Labels

Comments

@nvuillam
Copy link
Member

nvuillam commented Nov 5, 2023

Allow to configure command lines to call before and after a deployment

@nvuillam
Copy link
Member Author

@paferpo
Copy link

paferpo commented Sep 8, 2024

Is it possible to specify if the action is one time/recurring? It would useful to be able to specify that and storing the execution history in custom metadata/settings in each org to determine if it was already executed or not. Also a flag to don’t run them during PR validations.

@nvuillam nvuillam reopened this Sep 8, 2024
@nvuillam
Copy link
Member Author

nvuillam commented Sep 8, 2024

@paferpo about one-time / recurring... as sfdx-hardis is stateless, I don't know where to store it :/

About the flag to run them only during deploy validation or effective deployments, I'm working on it with v5, you'll be able to use it soon :)

@paferpo
Copy link

paferpo commented Sep 8, 2024

Hi Nicolas, as I mentioned in my previous message, it can be stored in custom settings records of each org where you are deploying to and, with a simple query, you can check if the action id was already executed (check only when the action is one-time of course).

@nvuillam
Copy link
Member Author

nvuillam commented Sep 8, 2024

@paferpo I get it, it's just that it would require such custom setting / metadata to be existing before the deployment ^^
I'll see what I can do :)

@paferpo
Copy link

paferpo commented Sep 9, 2024

I can think of 2 options in case it helps: either create the custom setting object + the action record on the fly when it doesn't exist (checking using metadata.list/metadata.read or just a query that will fail when the object does not exist) or, if that's too much work, just show a message saying that to use that option, the custom setting with name x must exist before, when it's not found.

@nvuillam
Copy link
Member Author

nvuillam commented Sep 9, 2024

I don't like the principle of uploading metadatas without the explicit acceptance from the user, so it will be option 2 :)
With a command to upload the metadata so users don't have to create it manually , like the connected app when configuring authentication :)

@nvuillam
Copy link
Member Author

nvuillam commented Sep 16, 2024

@paferpo

This is done in v5 (already tested and available using sf plugins install sfdx-hardis@alpha)

See documentation :)

https://github.com/hardisgroupcom/sfdx-hardis/blob/migrate-sf-plugin/docs/hardis/project/deploy/smart.md#deployment-pre-or-post-commands

I tested it with local test cases, but if you want to also test it and provide feedback it will be highly appreciated :)

@nvuillam nvuillam changed the title pre-deploy and post-deploy commands pre-deploy and post-deploy commands + context + runOnlyOnceByOrg Sep 16, 2024
@nvuillam nvuillam added the v5 label Sep 16, 2024
@paferpo
Copy link

paferpo commented Sep 16, 2024

Awesome! I will give a try in my ci/cd setup :)

@nvuillam
Copy link
Member Author

Awesome! I will give a try in my ci/cd setup :)

Happy to help :)
If it works, don't hesitate to post about it 🥳

@paferpo
Copy link

paferpo commented Sep 26, 2024

Hi Nicolas, I played with it. It works very well :)
As an improvement, it would be nice to have a folder e.g. "AutomatedActions" where you could have separate yaml files per action instead of having all defined in sfdx-hardis.yml, but not a biggie!

@nvuillam
Copy link
Member Author

nvuillam commented Sep 26, 2024

@paferpo glad it works for your use case:)
actions can be branch-scoped so I prefer to let them in the branch-scoped .sfdx-hardis.yml file :)

@nvuillam
Copy link
Member Author

@paferpo and please star the repository :) ( and post about it if it's your style ;) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants