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

Semaphore 2 : missing auto_cancel parameter in semaphore.yml #12

Closed
Thomas-Nedap opened this issue Jan 28, 2020 · 1 comment · Fixed by #13
Closed

Semaphore 2 : missing auto_cancel parameter in semaphore.yml #12

Thomas-Nedap opened this issue Jan 28, 2020 · 1 comment · Fixed by #13

Comments

@Thomas-Nedap
Copy link

Following some usage statistics we have dug into some configuration tweaks for Semaphore 2.

We noticed that this project has no auto_cancel option set for its pipeline.

Auto-cancel Previous Pipelines on a New Push
--- https://docs.semaphoreci.com/use-cases/auto-cancel-previous-pipelines-on-a-new-push/

This parameter simply tells Semaphore to cancel any running pipeline if a new push is done.
This can avoid having newer pushes wait for available resources to be run through the pipeline.

What to do

Here are two options you can pick from.

Auto cancel for all branches

This one is simple. You only need to had the following entry at the root of the semaphore.yml file. Just after the agent block.

auto_cancel:
  queued:
    when: "true" # enable auto-cancel for branches, tags and pull-requests

Do like @Flokkie97 : https://github.com/nedap/hera/blob/7b81b51e4abb6603cad7d1de8e8ba2bd3735a4da/.semaphore/semaphore.yml#L17-L19

Auto cancel but not for master

Master and releases branches might require to be built for every push or merge so that releasables are available.
To have such a conditional you can use the following added at the root of the semaphore.yml file.

You only need to had the following entry at the root of the semaphore.yml file. Just after the agent block.

auto_cancel:
  running:
    when: "branch != 'master'"

Do like @Flokkie97 (yes, he changed his mind) : https://github.com/nedap/hera/blob/master/.semaphore/semaphore.yml#L17-L19

Wrap up

There are cases where you might not want that included, and that's fine. Keep in mind that even
if you don't mind every push waiting it also potentially means other pushes from other team members are waiting for resources.

"...with great power there must also come -- great responsibility!"

@Thomas-Nedap
Copy link
Author

thanks

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 a pull request may close this issue.

1 participant