What about adding a new function for manipulating stages?
stage('production', function () {
set('deploy_path', '...');
host('domain.com')
->roles(['app']);
});
stage('staging', function () {
set('deploy_path', '...');
inventory('./inventory/staging.yml');
});
I think it's a great idea. It actually makes more sense to make the stage / environment a root element. You could do many things such as:
It is how PM2 Deployment works, and I believe it has only advantages. It is a great feature! Let me know if you need any help with implementation or tests, I'll be happy to help.
What about having separate file for each stage?
|- deploy.php
|- app
|- deploy
|- staging.php
|- production.php
set('stages', __DIR__ . '/app/deploy');
set('default_stage', 'staging');
set('branch', 'master');
host('production.com');
Personally I like to have all my deployment configuration in a single file. Since I have other config files (ex: phpunit, CI script, Dockerfile, Composer, gulp, npm, ...), I find it easier to have one file per tool. But my deployment scripts are usually quite simple, maybe this would be a good idea for projects with more complex scripts?
Do you like it?
stage('production', function () {
set('branch', 'production');
host('ec2-32-47-157-121.eu-west-1.compute.amazonaws.com');
host('ec2-52-37-137-111.ap-southeast-1.compute.amazonaws.com');
});
stage('staging', function () {
set('branch', 'development');
host('beta.project.com');
});
I would prefer something like
stage('production')
->set('branch', 'production')
->host('ec2-32-47-157-121.eu-west-1.compute.amazonaws.com')
->host('ec2-52-37-137-111.ap-southeast-1.compute.amazonaws.com');
});
stage('development')
->set('branch', 'development')
->host('beta.project.com');
});
to have it like the host() api which is also IDE friendly and allows autocompletion etc.
@staabm okay, how to do it:
stage('production', function () {
set('branch', 'production');
host('ec2-32-47-157-121.eu-west-1.compute.amazonaws.com')
->set('param', 'value');
host('ec2-52-37-137-111.ap-southeast-1.compute.amazonaws.com');
});
ok, I see.
I decided to remove the stage in the flavor of roles which eventually the same, but more functional. See #1904 for progress.