Skip to content

Commit 706e869

Browse files
Support ability to pass specific trigger for run operation (#322)
1 parent 52709bc commit 706e869

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

lib/interface/cli/commands/pipeline/run.base.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class RunBaseCommand {
2222
const userYamlDescriptor = this.argv.yaml;
2323
const contexts = this.argv.context;
2424
const noCfCache = this.argv['no-cf-cache'];
25+
const trigger = this.argv['trigger'];
2526

2627
const executionRequestTemplate = {
2728
pipelineName,
@@ -33,6 +34,7 @@ class RunBaseCommand {
3334
enableNotifications,
3435
userYamlDescriptor,
3536
noCfCache,
37+
trigger,
3638
},
3739
};
3840
if (variablesFromFile) {

lib/interface/cli/commands/pipeline/run.cf.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ function _buildBody(data) {
3838
if (data.contexts) {
3939
body.contexts = data.contexts;
4040
}
41+
42+
if (data.trigger) {
43+
body.trigger = data.trigger;
44+
}
4145
return body;
4246
}
4347

lib/interface/cli/commands/pipeline/run.cmd.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const run = new Command({
2323
},
2424
builder: (yargs) => {
2525
yargs
26+
.option('trigger', {
27+
describe: 'Trigger id or name',
28+
alias: 't',
29+
})
2630
.option('branch', {
2731
describe: 'Branch',
2832
alias: 'b',
@@ -78,6 +82,7 @@ const run = new Command({
7882
alias: 'ncfc',
7983
default: false,
8084
})
85+
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -trigger TRIGGER_ID | TRIGGER_NAME -b=master', 'Choosing a specific trigger')
8186
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master', 'Defining the source control context using a branch')
8287
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -s=52b992e783d2f84dd0123c70ac8623b4f0f938d1', 'Defining the source control context using a commit')
8388
.example('codefresh run PIPELINE_ID | PIPELINE_NAME -b=master -v key1=value1 -v key2=value2', 'Setting variables through the command')

lib/interface/cli/commands/pipeline/run.local.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class RunLocalCommand extends RunBaseCommand {
7171
async runImpl(request) {
7272
const { pipelineName } = request;
7373
const {
74-
branch, userYamlDescriptor, variables, noCache, resetVolume, noCfCache, enableNotifications,
74+
branch, userYamlDescriptor, variables, noCache, resetVolume, noCfCache, enableNotifications, trigger,
7575
} = request.options;
7676
const localVolume = this.argv['local-volume'] === true ?
7777
path.join(DEFAULTS.CODEFRESH_PATH, pipelineName) : this.argv['local-volume'];
@@ -105,6 +105,10 @@ class RunLocalCommand extends RunBaseCommand {
105105
injectedOpts.Env.push(`ENABLE_NOTIFICATIONS=${enableNotifications}`);
106106
}
107107

108+
if (trigger) {
109+
injectedOpts.Env.push(`TRIGGER=${trigger}`);
110+
}
111+
108112
const currentContext = sdk.config.context;
109113
console.log(`Running pipeline: ${pipelineName}`);
110114

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.17.14",
3+
"version": "0.18.0",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)