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

Conditional tasks #1140

Closed
antonmedv opened this issue Apr 3, 2017 · 3 comments
Closed

Conditional tasks #1140

antonmedv opened this issue Apr 3, 2017 · 3 comments
Labels

Comments

@antonmedv
Copy link
Member

Q A
Issue Type Feature Request
Deployer Version v5

Purpose: add prechecks for tasks and hooks.

before('some:task', 'other:task')->when(function() {
    // ...
});

task('some:task')->when(function() {
    // ...
});

When exactly should when's functions be executed?

@hstandaert
Copy link

hstandaert commented Apr 3, 2017

Function should be executed right before task execution. When false is returned, nothing should be outputted in the console.

Code sample:

deploy.php

server('prod_1', 'domain.com')
// ...

server('prod_2', 'domain.com')
// ...
->set('extra_stuff', '...');

task('some:task')->when(function() {
    return has('extra_stuff')
});
after('other:task', 'some:task')

Console output

$ dep deploy prod_1
...
> Executing task other:task

$ dep deploy prod_2
...
> Executing task other:task
> Executing task some:task

IMO, Syntax should be as illustrated in the code sample above, because all the code for a task is found in one place then.

@antonmedv
Copy link
Member Author

antonmedv commented Apr 3, 2017

What will lead to a bit complicated executor model. Also What about debug mode?

➤ Executing task deploy:prepare
[beta] > echo $0
[beta] < ssh multiplexing initialization
...
• done on [beta]
✔ Ok [4s 954ms]
[beta] > **CHECK WHEN COND HERE?**
[beta] < true
➤ Executing task deploy:release
[beta] > cd ~/beta && (if [ -h release ]; then echo 'true'; fi)
[beta] < true
...
➤ Executing task deploy:prepare
[beta] > echo $0
[beta] < ssh multiplexing initialization
...
• done on [beta]
✔ Ok [4s 954ms]
[beta] > **CHECK WHEN COND HERE?**
[beta] < false
...

@antonmedv
Copy link
Member Author

Done with invoke func.

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

No branches or pull requests

2 participants