title | layout | order |
---|---|---|
Stages |
doc_page.html |
4 |
In a step, the index.js
file implements the flow. The scaffold generates a file like this:
'use strict';
module.exports = {
check: function() {
this.logger.info('#blue', 'Check if all you need to execute this step exists');
},
config: function() {
this.logger.info('#yellow', 'Config the step to run');
},
run: function(ok, ko) {
this.sh('echo Run main execution of the step', ko, true);
},
prove: function() {
this.logger.info('#green', 'Check if the step has run ok');
},
notify: function() {
this.logger.info('#grey', 'Notify the end of the shot to someone or something');
},
emit: function() {
this.logger.info('#white', 'Emit the result of the step to other steps. Allow communication between steps');
return { message: 'emit a message' };
}
};
And the stages of a step by default are:
check
: check if all you need to execute this step exists.config
: config the step to run.run
: run main execution of the step.prove
: check if the step has run ok.notify
: notify the end of the step to someone or something.emit
: emit the result of the step to other steps. Allow communication between steps.
Note that all the stages are promises functions, they has two optional paramenter 'resolve', 'reject';
A example with resolve
and reject
:
module.exports = {
run: function(resolve, reject) {
if (this.params.jsonIsWellFormed) {
resolve();
} else {
reject();
}
return;
}
};
Check if all you need to execute this step exists. Here you can see some examples:
- System requirement. But check first requirements configuration options.
- Maybe check if some inputs are all well formed. For example a json well formed.
- Or check if the environment has a global variable setted.
- ...
Config the step to run. Do you need to config something, this is the stage to do it.
Run main execution of the step. This stage hope that all that it need to implement a process is 'ok', because it has been provide by the above stage.
Check if the step has run ok.
- If artifacts has been well built.
- or if there is a inexpected file created.
Notify the end of the shot to someone or something.
- Email to an address.
- Notify to a slack channel.
- ...
Emit the result of the step to other steps. Allow communication between steps.
See parameters between steps for more information.
Note:
Stages are configured on piscosour.json file of every recipe, it is possible to overwrite stages parameters on piscosour.json, see recipe configuration for more information.