Skip to content

Commit 52709bc

Browse files
filter builds (#321)
* add missing status * add formatter * builds filter by branch and revision
1 parent 0fc4501 commit 52709bc

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

lib/interface/cli/commands/workflow/get.cmd.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,51 @@ const command = new Command({
2424
describe: 'Build id',
2525
})
2626
.option('limit', {
27+
alias: 'l',
2728
describe: 'Limit amount of returned results',
2829
default: DEFAULTS.GET_LIMIT_RESULTS,
2930
})
3031
.option('page', {
32+
alias: 'p',
3133
describe: 'Paginated page',
3234
default: DEFAULTS.GET_PAGINATED_PAGE,
3335
})
3436
.option('status', {
37+
alias: 's',
3538
describe: 'Filter results by statuses',
3639
type: Array,
37-
choices: ['pending', 'elected', 'error', 'running', 'success', 'terminated', 'terminating'],
40+
choices: ['pending', 'elected', 'error', 'running', 'success', 'terminated', 'terminating', 'pending-approval'],
3841
})
3942
.option('trigger', {
43+
alias: 't',
4044
describe: 'Filter results by triggers',
4145
type: Array,
4246
choices: ['build', 'launch-image', 'launch-composition'],
4347
})
4448
.option('pipeline-id', {
49+
alias: 'pid',
4550
describe: 'Filter results by pipeline id',
4651
type: Array,
4752
default: [],
4853
})
4954
.option('pipeline-name', {
55+
alias: 'pipeline',
5056
describe: 'Filter results by pipeline name',
5157
type: Array,
5258
default: [],
5359
})
60+
.option('branch', {
61+
alias: 'b',
62+
describe: 'Filter results by branch',
63+
type: Array,
64+
default: [],
65+
})
66+
.option('commit-id', {
67+
alias: ['revision', 'r', 'sha'],
68+
describe: 'Filter results by commit revision sha',
69+
type: Array,
70+
default: [],
71+
})
5472
.example('codefresh get build ID', 'Get build ID')
5573
.example('codefresh get builds', 'Get all builds')
5674
.example('codefresh get builds --pipeline-id ID', 'Get all builds that are executions of pipeline "ID"')
@@ -60,7 +78,14 @@ const command = new Command({
6078
},
6179
handler: async (argv) => {
6280
const workflowIds = argv.id;
63-
const { limit, page, status, trigger } = argv;
81+
const {
82+
limit,
83+
page,
84+
status,
85+
trigger,
86+
branch: branchName,
87+
commitId: revision,
88+
} = argv;
6489
const pipelineNames = !_.isArray(argv['pipeline-name']) ? [(argv['pipeline-name'])] : argv['pipeline-name'];
6590
const pipelineIds = !_.isArray(argv['pipeline-id']) ? [(argv['pipeline-id'])] : argv['pipeline-id'];
6691

@@ -87,6 +112,8 @@ const command = new Command({
87112
page,
88113
status,
89114
trigger,
115+
branchName,
116+
revision,
90117
pipeline: _.isEmpty(pipelineIds) ? undefined : pipelineIds,
91118
});
92119
Output.print(result.workflows.docs.map(Workflow.fromResponse));

lib/output/formatters/Workflow.formatter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const STATUS_CHOICES = {
1212
error: Style.red.appendedBy(CROSS_SIGN),
1313
terminated: Style.red.appendedBy(CROSS_SIGN),
1414
pending: Style.yellow.appendedBy(CIRCLE_SIGN),
15+
'pending-approval': Style.yellow.appendedBy(CIRCLE_SIGN),
1516
elected: Style.yellow.appendedBy(BRACKET_SIGN),
1617
running: Style.cyan.appendedBy(PLAY_SIGN),
1718
terminating: Style.red.appendedBy(TWO_ARR_DOWN_SIGN),

openapi.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,22 @@
16451645
"schema": {
16461646
"type": "string"
16471647
}
1648+
},
1649+
{
1650+
"name": "revision",
1651+
"in": "query",
1652+
"schema": {
1653+
"type": "string"
1654+
},
1655+
"description": "revision sha"
1656+
},
1657+
{
1658+
"name": "branchName",
1659+
"in": "query",
1660+
"schema": {
1661+
"type": "string"
1662+
},
1663+
"description": "branch name"
16481664
}
16491665
],
16501666
"responses": {

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.12",
3+
"version": "0.17.14",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)