Skip to content

Commit 5b95fa0

Browse files
Feature/olegz/saas 5027 running pipeline only with yaml (#395)
* SAAS-5027 #time Added ability to run pipeline without name, only with yaml file * SAAS-5027 #time Added ability to run pipeline without name, only with yaml file * SAAS-5027 #time Added ability to run pipeline without name, only with yaml file * SAAS-5027 #time 10m 0h remove new flag `shadowRunning`. Added new error * SAAS-5027 #time 0m 0h Added default pipeline name '', because with `undefined` param, request sends like `/pipelines/run/,` * SAAS-5027 #time 0m 0h Added new route for shadow running pipeline * SAAS-5027 #time 0m 0h Fixed openapi.json * SAAS-5027 #time 0m 0h Removed default value, added _selectInterfaceMethod
1 parent ede39c5 commit 5b95fa0

File tree

4 files changed

+65
-9
lines changed

4 files changed

+65
-9
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class RunBaseCommand {
1414

1515
async run() {
1616
await this.preRunRequest();
17-
const { debug, skip, only, trigger, cpu, memory, branch, sha, disk } = this.argv;
17+
const {
18+
debug, skip, only, trigger, cpu, memory, branch, sha, disk,
19+
} = this.argv;
1820
const variablesFromFile = this.argv['var-file'];
1921
const pipelineName = this.argv.name;
2022
const noCache = this.argv['no-cache'];
@@ -88,12 +90,20 @@ class RunBaseCommand {
8890
const pipelineName = this.argv.name;
8991
const userYamlDescriptor = this.argv.yaml;
9092
const contexts = this.argv.context;
91-
try {
92-
await sdk.pipelines.get({ name: pipelineName });
93-
} catch (err) {
94-
throw new CFError({
95-
message: `Passed pipeline id: ${pipelineName} does not exist`,
96-
});
93+
if (!pipelineName) {
94+
if (!userYamlDescriptor) {
95+
throw new CFError({
96+
message: 'You need to specify pipelineName or the yaml file',
97+
});
98+
}
99+
} else {
100+
try {
101+
await sdk.pipelines.get({ name: pipelineName });
102+
} catch (err) {
103+
throw new CFError({
104+
message: `Passed pipeline id: ${pipelineName} does not exist`,
105+
});
106+
}
97107
}
98108

99109
if (userYamlDescriptor) {

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ function _buildBody(data) {
2626
class RunExternalCommand extends RunBaseCommand {
2727
async runImpl(request) {
2828
const { pipelineName, options = {} } = request;
29-
const interfaceMethod = options.debug ? 'debug' : 'run';
29+
const interfaceMethod = this._selectInterfaceMethod({
30+
pipelineName,
31+
options,
32+
});
3033
this.workflowId = await sdk.pipelines[interfaceMethod]({ name: pipelineName }, _buildBody(options));
3134
if (this.executionRequests.length === 1) {
3235
if (this.argv.detach) {
@@ -37,6 +40,16 @@ class RunExternalCommand extends RunBaseCommand {
3740
}
3841
console.log(this.workflowId);
3942
}
43+
44+
_selectInterfaceMethod({ pipelineName, options }) {
45+
if (options.debug) {
46+
return 'debug';
47+
}
48+
if (!pipelineName && options.userYamlDescriptor) {
49+
return 'runYaml';
50+
}
51+
return 'run';
52+
}
4053
}
4154

4255
module.exports = RunExternalCommand;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function getCommandFlavor(argv) {
1313

1414
const run = new Command({
1515
root: true,
16-
command: 'run <name>',
16+
command: 'run [name]',
1717
description: 'Run a pipeline by id or name and attach the created workflow logs.',
1818
usage: 'Returns an exit code according to the workflow finish status (Success: 0, Error: 1, Terminated: 2)',
1919
webDocs: {

openapi.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,6 +5278,39 @@
52785278
"x-sdk-interface": "pipelines.create"
52795279
}
52805280
},
5281+
"/pipelines/run": {
5282+
"post": {
5283+
"responses": {
5284+
"200": {
5285+
"description": "ok",
5286+
"headers": {
5287+
"Location": {
5288+
"schema": {
5289+
"type": "string"
5290+
},
5291+
"description": "Endpoint to query the build status"
5292+
}
5293+
}
5294+
}
5295+
},
5296+
"tags": [
5297+
"pipelines"
5298+
],
5299+
"operationId": "pipelines-run-yaml",
5300+
"parameters": [],
5301+
"requestBody": {
5302+
"content": {
5303+
"application/json": {
5304+
"schema": {
5305+
"type": "object"
5306+
}
5307+
}
5308+
}
5309+
},
5310+
"summary": "Run yaml",
5311+
"x-sdk-interface": "pipelines.runYaml"
5312+
}
5313+
},
52815314
"/pipelines/run/{name}": {
52825315
"post": {
52835316
"responses": {

0 commit comments

Comments
 (0)