Skip to content

Commit a437fcb

Browse files
authored
New Components - circleci (#15009)
* circleci init * new components * pnpm-lock.yaml * updates * add alert prop
1 parent 158e8cb commit a437fcb

File tree

11 files changed

+776
-4
lines changed

11 files changed

+776
-4
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import circleci from "../../circleci.app.mjs";
2+
3+
export default {
4+
key: "circleci-get-job-artifacts",
5+
name: "Get Job Artifacts",
6+
description: "Retrieves a job's artifacts. [See the documentation](https://circleci.com/docs/api/v2/index.html#tag/Job/operation/getJobArtifacts).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
circleci,
11+
projectSlug: {
12+
propDefinition: [
13+
circleci,
14+
"projectSlug",
15+
],
16+
},
17+
pipelineId: {
18+
propDefinition: [
19+
circleci,
20+
"pipelineId",
21+
(c) => ({
22+
projectSlug: c.projectSlug,
23+
}),
24+
],
25+
},
26+
workflowId: {
27+
propDefinition: [
28+
circleci,
29+
"workflowId",
30+
(c) => ({
31+
pipelineId: c.pipelineId,
32+
}),
33+
],
34+
},
35+
jobNumber: {
36+
propDefinition: [
37+
circleci,
38+
"jobNumber",
39+
(c) => ({
40+
workflowId: c.workflowId,
41+
}),
42+
],
43+
},
44+
},
45+
async run({ $ }) {
46+
const response = await this.circleci.getJobArtifacts({
47+
$,
48+
projectSlug: this.projectSlug,
49+
jobNumber: this.jobNumber,
50+
});
51+
$.export("$summary", `Successfully retrieved artifacts for job number: ${this.jobNumber}`);
52+
return response;
53+
},
54+
};
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import circleci from "../../circleci.app.mjs";
2+
3+
export default {
4+
key: "circleci-rerun-workflow",
5+
name: "Rerun Workflow",
6+
description: "Reruns the specified workflow. [See the documentation](https://circleci.com/docs/api/v2/index.html#tag/Workflow/operation/rerunWorkflow)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
circleci,
11+
projectSlug: {
12+
propDefinition: [
13+
circleci,
14+
"projectSlug",
15+
],
16+
},
17+
pipelineId: {
18+
propDefinition: [
19+
circleci,
20+
"pipelineId",
21+
(c) => ({
22+
projectSlug: c.projectSlug,
23+
}),
24+
],
25+
},
26+
workflowId: {
27+
propDefinition: [
28+
circleci,
29+
"workflowId",
30+
(c) => ({
31+
pipelineId: c.pipelineId,
32+
}),
33+
],
34+
},
35+
enableSsh: {
36+
type: "boolean",
37+
label: "Enable SSH",
38+
description: "Whether to enable SSH access for the triggering user on the newly-rerun job. Requires the jobs parameter to be used and so is mutually exclusive with the from_failed parameter.",
39+
optional: true,
40+
},
41+
fromFailed: {
42+
type: "boolean",
43+
label: "From Failed",
44+
description: "Whether to rerun the workflow from the failed job. Mutually exclusive with the jobs parameter.",
45+
optional: true,
46+
},
47+
jobIds: {
48+
propDefinition: [
49+
circleci,
50+
"jobIds",
51+
(c) => ({
52+
workflowId: c.workflowId,
53+
}),
54+
],
55+
},
56+
sparseTree: {
57+
type: "boolean",
58+
label: "Sparse Tree",
59+
description: "",
60+
optional: true,
61+
},
62+
},
63+
async run({ $ }) {
64+
const response = await this.circleci.rerunWorkflow({
65+
$,
66+
workflowId: this.workflowId,
67+
data: {
68+
enable_ssh: this.enableSsh,
69+
from_failed: this.fromFailed,
70+
jobs: typeof this.jobIds === "string"
71+
? JSON.parse(this.jobIds)
72+
: this.jobIds,
73+
sparse_tree: this.sparseTree,
74+
},
75+
});
76+
$.export("$summary", `Successfully started a rerun of workflow with ID: ${this.workflowId}`);
77+
return response;
78+
},
79+
};
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import circleci from "../../circleci.app.mjs";
2+
3+
export default {
4+
key: "circleci-trigger-pipeline",
5+
name: "Trigger a Pipeline",
6+
description: "Trigger a pipeline given a pipeline definition ID. Supports all integrations except GitLab. [See the documentation](https://circleci.com/docs/api/v2/index.html#tag/Pipeline/operation/triggerPipelineRun)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
circleci,
11+
alert: {
12+
type: "alert",
13+
alertType: "info",
14+
content: "Supports all integrations except GitLab.",
15+
},
16+
projectSlug: {
17+
propDefinition: [
18+
circleci,
19+
"projectSlug",
20+
],
21+
},
22+
definitionId: {
23+
type: "string",
24+
label: "Definition ID",
25+
description: "The unique ID for the pipeline definition. This can be found in the page Project Settings > Pipelines.",
26+
},
27+
configBranch: {
28+
type: "string",
29+
label: "Config Branch",
30+
description: "The branch that should be used to fetch the config file. Note that branch and tag are mutually exclusive. To trigger a pipeline for a PR by number use pull//head for the PR ref or pull//merge for the merge ref (GitHub only)",
31+
optional: true,
32+
},
33+
configTag: {
34+
type: "string",
35+
label: "Config Tag",
36+
description: "The tag that should be used to fetch the config file. The commit that this tag points to is used for the pipeline. Note that branch and tag are mutually exclusive.",
37+
optional: true,
38+
},
39+
checkoutBranch: {
40+
type: "string",
41+
label: "Checkout Branch",
42+
description: "The branch that should be used to check out code on a checkout step. Note that branch and tag are mutually exclusive. To trigger a pipeline for a PR by number use pull//head for the PR ref or pull//merge for the merge ref (GitHub only)",
43+
optional: true,
44+
},
45+
checkoutTag: {
46+
type: "string",
47+
label: "Checkout Tag",
48+
description: "The tag that should be used to check out code on a checkout step. The commit that this tag points to is used for the pipeline. Note that branch and tag are mutually exclusive.",
49+
optional: true,
50+
},
51+
parameters: {
52+
type: "object",
53+
label: "Parameters",
54+
description: "An object containing pipeline parameters and their values. Pipeline parameters have the following size limits: 100 max entries, 128 maximum key length, 512 maximum value length.",
55+
optional: true,
56+
},
57+
},
58+
async run({ $ }) {
59+
const response = await this.circleci.triggerPipeline({
60+
$,
61+
projectSlug: this.projectSlug,
62+
data: {
63+
definition_id: this.definitionId,
64+
config: this.configBranch || this.configTag
65+
? {
66+
branch: this.configBranch,
67+
tag: this.configTag,
68+
}
69+
: undefined,
70+
checkout: this.checkoutBranch || this.checkoutTag
71+
? {
72+
branch: this.checkoutBranch,
73+
tag: this.checkoutTag,
74+
}
75+
: undefined,
76+
parameters: typeof this.parameters === "string"
77+
? JSON.parse(this.parameters)
78+
: this.parameters,
79+
},
80+
});
81+
82+
if (response?.id) {
83+
$.export("$summary", `Successfully triggered pipeline with ID: ${response.id}`);
84+
}
85+
return response;
86+
},
87+
};

0 commit comments

Comments
 (0)