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

feat(beforeJobError): introduce BeforeJobError as a new Eventlistener #812

Closed
wants to merge 1 commit into from

Conversation

FalcoSuessgott
Copy link
Contributor

@FalcoSuessgott FalcoSuessgott commented Jan 8, 2025

What does this do?

This PR adds a new EventListener BeforeJobRunsError that exits job execution if the provided func returns an error

Use Case:
Im using gocron as a command wrapper for terraform to perform synthetic monitoring checks and came up with a configuration as follows:

settings:
  interval: 10s
  extra_labels:
    development: true

tests:
  vmware_vm:
    env:
      TF_VAR_content: "This is a variable"

    before_script:
      - cmd: terraform init
        retries: 2

    script:
      - cmd: terraform apply -auto-approve

    after_script:
      - cmd: terraform destroy -auto-approve

Where as the commands specified in the before_script block would be passed to BeforeJobRuns(), without this PR there was no way to stop the currents jobs execution in case of an error in one of the commands in before_script.

Introducing BeforeJobRunsError allows me to exit the jobs execution gracefully and try again after the configured interval.

List any changes that modify/break current functionality

none

Have you included tests for your changes?

Did you document any new/modified functionality?

  • Updated example_test.go
  • Updated README.md

Notes

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

Successfully merging this pull request may close these issues.

1 participant