Deployer: Is there a way to check what stage is set in a task?

Created on 21 Jan 2017  路  5Comments  路  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Question
| Deployer Version | 4.0.2
| Local Machine OS | Windows 7
| Remote Machine OS | CentOS 7

Description

Was just wondering if there was a way to check what stage was set when deploying, as I'm using a task that seeds the database, but depending on the stage set, it would have to correctly seed the right data.

Thanks!

Most helpful comment

Notice that you should use get('stages') instead, env() is gone in 4.x.

All 5 comments

stages are available through env and use can use it as below

    if (isTesting()) {
        set('keep_releases', 1);
    } else {
        set('keep_releases', 10);
    }
function isTesting()
{
    $stages = env('stages');
    return reset($stages) === 'testing';
}

Notice that you should use get('stages') instead, env() is gone in 4.x.

Thank you! I've got it working.

But why does input()->hasArgument('stage') return true while input()->getArgument('stage') returns NULL ?
Altogether while var_dump(get('stages')); returns an array with one entry containing the stage i'm curently deploying to...

@klefix looks like a bug. Also i think it will be cool get better API for get('stages') (maybe return all stages instead of only one)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

k-solnushkin picture k-solnushkin  路  5Comments

minkbear picture minkbear  路  4Comments

osbulbul picture osbulbul  路  3Comments

ovaiskhan11 picture ovaiskhan11  路  4Comments

lsv picture lsv  路  4Comments