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

Add a commands Property to the Pre/Post Workflow Hooks to Allow Targeted Execution #3703

Closed
1 task done
X-Guardian opened this issue Aug 25, 2023 · 6 comments · Fixed by #3708
Closed
1 task done
Labels
feature New functionality/enhancement

Comments

@X-Guardian
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Describe the user story

As an Atlantis user, I would like to be able to run different pre/post workflow hooks for certain Atlantis commands, without needing to add logic to the script to check environment variables.

Describe the solution you'd like

Add an additional property commands to the workflow hook definition that would allow the specification of a list of Atlantis commands that the particular hook would run for.

Example

repos:
    - id: /.*/
      pre_workflow_hooks:
        - run: plan-hook.sh
          description: Plan Hook
          commands: plan
        - run: plan-apply-hook.sh
          description: Plan & Apply Hook
          commands: plan, apply

This config would run the plan-hook.sh script only on execution of plan commands, and the plan-apply-hook.sh script on the execution of plan and apply commands.

If the commands property is not present, the script would continue to be run on the execution of any command.

Describe the drawbacks of your solution

None

Describe alternatives you've considered

Continue using script logic to check the COMMAND_NAME environment variable.

@X-Guardian X-Guardian added the feature New functionality/enhancement label Aug 25, 2023
@jamengual
Copy link
Contributor

are you sure this is possible? I do not believe a pre_workflow will know about the command executed since it runs before that happens. a post_workflow hook might be able to do this.

@X-Guardian
Copy link
Contributor Author

Sure it knows. We already set an environment variable with the command name: #3571

@jamengual
Copy link
Contributor

ok, cool

@GMartinez-Sisti
Copy link
Member

This is missing from the documentation. Should we re-open or create a new issue for it?

@X-Guardian
Copy link
Contributor Author

It is documented here and here.

@GMartinez-Sisti
Copy link
Member

Thanks! I was looking here.

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

Successfully merging a pull request may close this issue.

3 participants