Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
+++
title = "Spec"
weight = 10
+++

A Pipeline needs `.apiVersion`, `.kind`, and `.metadata` fields.
Expand All @@ -15,8 +14,12 @@ apiVersion: "v1"
kind: "pipeline"
metadata:
name: "new-pipeline"
description: "my description"
labels:
repo: "github:ArikMaor/ping-server"
repo: "ArikMaor/ping-server"
key1: "value1"
project: "asd"

spec:
triggers:
- type: "scm"
Expand All @@ -32,13 +35,25 @@ spec:
value: "BLA BLA"
encrypted: true
steps:
test_step:
clone_step:
repo: github.com/itai-codefresh/test-env-file
revision: master
test_step_1:
image: "alpine"
working_directory: ${{clone_step}}
commands:
- echo ls
- echo "hello world"
- echo "plain value $PORT"
- echo "encrypted value $PAPA"
- echo "value from context $COOKIE"
build:
type: build
working_directory: ${{clone_step}}
dockerfile: ./Dockerfile
image_name: itai/test
tag: bla

```

#### Pipeline which is stored on a remote git
Expand All @@ -48,7 +63,7 @@ kind: "pipeline"
metadata:
name: "ew-pipeline-git"
labels:
repo: "github:ArikMaor/ping-server"
repo: "ArikMaor/ping-server"
spec:
triggers:
- type: "scm"
Expand Down Expand Up @@ -76,7 +91,7 @@ kind: "pipeline"
metadata:
name: "new-pipeline-url"
labels:
repo: "github:codefresh-io/cli"
repo: "codefresh-io/cli"
spec:
triggers:
- type: "scm"
Expand Down
7 changes: 0 additions & 7 deletions docs/content/pipelines v2/_index.md

This file was deleted.

5 changes: 3 additions & 2 deletions docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ const CFError = require('cf-errors');

const TEMP_DIR = path.resolve(__dirname, '../temp');
const TEMPLATE_DIR = path.resolve(__dirname);
const FILES_TO_IGNORE = ['index.js', 'content/pipelines v2/_index.md', 'content/pipelines v2/spec.md'];
const FILES_TO_IGNORE = ['index.js'];
const baseDir = path.resolve(TEMP_DIR, './content');
const ALLOW_BETA_COMMANDS = process.env.ALLOW_BETA_COMMANDS;
const categoriesOrder = {
authentication: 30,
pipelines : 40,
'pipelines v2 (beta)' : 42,
builds: 50,
'operate on resources' : 60,
contexts : 70 ,
Expand Down Expand Up @@ -340,7 +341,7 @@ const createDownloadPage = async () => {
const RequestOptions = {
url: 'https://api.github.com/repos/codefresh-io/cli/releases/latest',
headers: {
'User-Agent': 'codefresh-cli}',
'User-Agent': 'codefresh-cli-build',
},
json: true,
};
Expand Down
37 changes: 0 additions & 37 deletions lib/interface/cli/commands/context/replace.cmd.js

This file was deleted.

45 changes: 12 additions & 33 deletions lib/interface/cli/commands/pipeline/run.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ const _ = require('lodash');
const CFError = require('cf-errors');
const { prepareKeyValueFromCLIEnvOption, crudFilenameOption } = require('../../helpers/general');
const ObjectID = require('mongodb').ObjectID;
const { workflow, pipeline, pipeline2, log } = require('../../../../logic').api;
const authManager = require('../../../../logic').auth.manager;

const { workflow, pipeline, log } = require('../../../../logic').api;

const run = new Command({
root: true,
Expand Down Expand Up @@ -79,34 +77,20 @@ const run = new Command({
const variablesFromFile = argv['var-file'];
const contexts = argv['context'];

if (!authManager.getCurrentContext()
.isBetaFeatEnabled()) {
// validate that passed pipeline id an a mongo object id in case of pipeline V1
if (!ObjectID.isValid(pipelineId)) {
throw new CFError({
message: `Passed pipeline id: ${pipelineId} is not valid`,
});
}
if (!ObjectID.isValid(pipelineId)) {
throw new CFError({
message: `Passed pipeline id: ${pipelineId} is not valid`,
});
}

let pipelineVersion = 'v1';
if (authManager.getCurrentContext()
.isBetaFeatEnabled()) {
try {
await pipeline.getPipelineById(pipelineId);
} catch (err) {
try {
await pipeline2.getPipelineByName(pipelineId);
pipelineVersion = 'v2';
} catch (err) {
throw new CFError({
message: `Passed pipeline id: ${pipelineId} does not exist`,
});
}
}
try {
await pipeline.getPipelineById(pipelineId);
} catch (err) {
throw new CFError({
message: `Passed pipeline id: ${pipelineId} does not exist`,
});
}


const executionRequests = [];
const executionRequestTemplate = {
pipelineId,
Expand All @@ -133,12 +117,7 @@ const run = new Command({
}

_.forEach(executionRequests, async ({ pipelineId, options }) => {
let workflowId;
if (pipelineVersion === 'v1') {
workflowId = await pipeline.runPipelineById(pipelineId, options);
} else {
workflowId = await pipeline2.runPipelineByName(pipelineId, options);
}
const workflowId = await pipeline.runPipelineById(pipelineId, options);

if (executionRequests.length === 1) {
if (argv.detach) {
Expand Down
32 changes: 0 additions & 32 deletions lib/interface/cli/commands/pipeline2/create.cmd.js

This file was deleted.

12 changes: 5 additions & 7 deletions lib/interface/cli/commands/pipeline2/delete.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ const debug = require('debug')('codefresh:cli:create:pipelines2');
const Command = require('../../Command');
const CFError = require('cf-errors');
const _ = require('lodash');
const { pipeline2 } = require('../../../../logic').api;
const { specifyOutputForSingle, specifyOutputForArray } = require('../../helpers/get');
const { pipeline2: pipeline } = require('../../../../logic').api;
const deleteRoot = require('../root/delete.cmd');


const command = new Command({
betaCommand: true,
command: 'pipeline2 [name]',
aliases: ['pip2'],
command: 'pipeline-v2 [name]',
aliases: ['pip-v2'],
parent: deleteRoot,
description: 'Delete a pipeline',
webDocs: {
category: 'Pipelines V2',
category: 'Pipelines V2 (beta)',
title: 'Delete Pipeline',
},
builder: (yargs) => {
Expand All @@ -26,7 +24,7 @@ const command = new Command({
handler: async (argv) => {
const {name} = argv;

await pipeline2.deletePipelineByName(name);
await pipeline.deletePipelineByName(name);
console.log(`Pipeline '${name}' deleted.`);
},
});
Expand Down
63 changes: 50 additions & 13 deletions lib/interface/cli/commands/pipeline2/get.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,76 @@ const debug = require('debug')('codefresh:cli:create:pipelines2');
const Command = require('../../Command');
const CFError = require('cf-errors');
const _ = require('lodash');
const { pipeline2 } = require('../../../../logic').api;
const { specifyOutputForSingle, specifyOutputForArray } = require('../../helpers/get');
const DEFAULTS = require('../../defaults');
const { pipeline2: pipeline } = require('../../../../logic').api;
const { prepareKeyValueFromCLIEnvOption, printError } = require('../../helpers/general');
const { specifyOutputForArray } = require('../../helpers/get');

const getRoot = require('../root/get.cmd');


const command = new Command({
betaCommand: true,
command: 'pipelines2 [name..]',
aliases: ['pip2', 'pipeline2'],
command: 'pipelines-v2 [name..]',
aliases: ['pip-v2', 'pipeline-v2'],
parent: getRoot,
description: 'Get a specific pipeline or an array of pipelines',
webDocs: {
category: 'Pipelines V2',
title: 'Get Pipeline V2',
category: 'Pipelines V2 (beta)',
title: 'Get Pipeline',
},
builder: (yargs) => {
return yargs
.positional('name', {
describe: 'Pipeline name',
})
.option('name-regex', {
describe: 'Filter pipelines by name',
})
.option('label', {
describe: 'Filter by a label',
alias: 'l',
default: [],
})
.option('limit', {
describe: 'Limit amount of returned results',
default: DEFAULTS.GET_LIMIT_RESULTS,
})
.option('page', {
describe: 'Paginated page',
default: DEFAULTS.GET_PAGINATED_PAGE,
});
},
handler: async (argv) => {
const {names, output} = argv;
let pipelines = [];
const {name: names, output} = argv;
const limit = argv.limit;
const offset = (argv.page - 1) * limit;
const nameRegex = argv['name-regex'];
const labels = prepareKeyValueFromCLIEnvOption(argv.label);


const pipelines = [];
if (!_.isEmpty(names)) {
for (const name of names) {
const currPipeline = await pipeline2.getPipelineByName(name);
pipelines.push(currPipeline);
try {
const currPipeline = await pipeline.getPipelineByName(name);
pipelines.push(currPipeline);
} catch (err) {
const message = err.toString()
.includes('404') ? `Pipeline '${name}' was not found.` : 'Error occurred';
throw new CFError({
cause: err,
message,
});
}
}
} else {
pipelines = await pipeline2.getAll();
specifyOutputForArray(output, await pipeline.getAll({
limit,
offset,
nameRegex,
labels,
}));
}
specifyOutputForArray(output, pipelines);
},
});

Expand Down
Loading