Custom step file support

pull/437/head
Frostebite 2022-10-08 02:35:21 +01:00
parent 45a2ee60f0
commit a807b8dff6
3 changed files with 33 additions and 40 deletions

12
dist/index.js vendored
View File

@ -4448,6 +4448,9 @@ class CloudRunnerCustomSteps {
return results;
}
static ConvertYamlSecrets(object) {
if (object.secrets === undefined) {
return;
}
object.secrets = object.secrets.map((x) => {
return {
ParameterKey: x.name,
@ -4460,13 +4463,11 @@ class CloudRunnerCustomSteps {
if (steps === '') {
return [];
}
let object;
try {
if (cloud_runner_1.default.buildParameters.cloudRunnerIntegrationTests) {
cloud_runner_logger_1.default.log(`Parsing build steps: ${steps}`);
}
const isArray = steps[0] === `-`;
object = isArray ? yaml_1.default.parse(steps) : [yaml_1.default.parse(steps)];
const object = isArray ? yaml_1.default.parse(steps) : [yaml_1.default.parse(steps)];
if (isArray) {
for (const step of object) {
CloudRunnerCustomSteps.ConvertYamlSecrets(step);
@ -4478,11 +4479,6 @@ class CloudRunnerCustomSteps {
if (object === undefined) {
throw new Error(`Failed to parse ${steps}`);
}
}
catch (error) {
cloud_runner_logger_1.default.log(`failed to parse a custom job "${steps} \n ${JSON.stringify(error, undefined, 4)}"`);
throw error;
}
return object;
}
static RunPostBuildSteps(cloudRunnerStepState) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -32,6 +32,9 @@ export class CloudRunnerCustomSteps {
}
private static ConvertYamlSecrets(object) {
if (object.secrets === undefined) {
return;
}
object.secrets = object.secrets.map((x) => {
return {
ParameterKey: x.name,
@ -45,13 +48,11 @@ export class CloudRunnerCustomSteps {
if (steps === '') {
return [];
}
let object: any;
try {
if (CloudRunner.buildParameters.cloudRunnerIntegrationTests) {
CloudRunnerLogger.log(`Parsing build steps: ${steps}`);
}
const isArray = steps[0] === `-`;
object = isArray ? YAML.parse(steps) : [YAML.parse(steps)];
const object: CustomStep[] = isArray ? YAML.parse(steps) : [YAML.parse(steps)];
if (isArray) {
for (const step of object) {
CloudRunnerCustomSteps.ConvertYamlSecrets(step);
@ -62,10 +63,6 @@ export class CloudRunnerCustomSteps {
if (object === undefined) {
throw new Error(`Failed to parse ${steps}`);
}
} catch (error) {
CloudRunnerLogger.log(`failed to parse a custom job "${steps} \n ${JSON.stringify(error, undefined, 4)}"`);
throw error;
}
return object;
}