Skip to content

Commit 75d5eb3

Browse files
authored
Adds a run-runbook step in Octopus Deploy (#703)
* Adds a run-runbook step * Change icon background color
1 parent 1649290 commit 75d5eb3

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed
Lines changed: 14 additions & 0 deletions
Loading
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
version: "1.0"
2+
kind: step-type
3+
metadata:
4+
name: octopusdeploy-run-runbook
5+
version: 1.0.0
6+
title: Run a runbook in Octopus Deploy
7+
isPublic: true
8+
description: Run a runbook in Octopus Deploy
9+
sources:
10+
- "https://github.com/codefresh-io/steps/tree/master/incubating/octopusdeploy-run-runbook"
11+
stage: incubating
12+
official: true
13+
categories:
14+
- deployment
15+
icon:
16+
type: svg
17+
url: "https://cdn.jsdelivr.net/gh/codefresh-io/steps/incubating/octopusdeploy-run-runbook/run_a_runbook.svg"
18+
background: "#F4F6F8"
19+
maintainers:
20+
- name: OctopusDeploy
21+
examples:
22+
- description: Basic usage of the run a runbook step
23+
workflow:
24+
run-runbook:
25+
type: octopusdeploy-run-runbook
26+
arguments:
27+
OCTOPUS_API_KEY: "${{OCTOPUS_API_KEY}}"
28+
OCTOPUS_URL: "${{OCTOPUS_URL}}"
29+
OCTOPUS_SPACE: "Spaces 1"
30+
PROJECT: "Project Name"
31+
NAME: "Runbook Name"
32+
ENVIRONMENTS:
33+
- "Development"
34+
- "Production"
35+
- description: Complex usage of the run a runbook step
36+
workflow:
37+
run-runbook:
38+
type: octopusdeploy-run-runbook
39+
arguments:
40+
OCTOPUS_API_KEY: "${{OCTOPUS_API_KEY}}"
41+
OCTOPUS_URL: "${{OCTOPUS_URL}}"
42+
OCTOPUS_SPACE: "Spaces 1"
43+
PROJECT: "Project Name"
44+
NAME: "Runbook Name"
45+
ENVIRONMENTS:
46+
- "Development"
47+
- "Production"
48+
VARIABLES:
49+
- "Label:Value"
50+
TENANTS:
51+
- "Tenant 1"
52+
TENANT_TAGS:
53+
- "Tenant tag 1"
54+
USE_GUIDED_FAILURE: "false"
55+
spec:
56+
arguments: |-
57+
{
58+
"definitions": {},
59+
"$schema": "http://json-schema.org/draft-07/schema#",
60+
"type": "object",
61+
"name": "octopusdeploy-run-runbook",
62+
"additionalProperties": false,
63+
"patterns": [],
64+
"required": ["OCTOPUS_API_KEY", "OCTOPUS_URL", "OCTOPUS_SPACE", "PROJECT", "NAME", "ENVIRONMENTS"],
65+
"properties": {
66+
"OCTOPUS_API_KEY": {
67+
"type": "string",
68+
"description": "API key for octopus deploy (required)"
69+
},
70+
"OCTOPUS_URL": {
71+
"type": "string",
72+
"description": "URL of the octopus deploy server (required)"
73+
},
74+
"OCTOPUS_SPACE": {
75+
"type": "string",
76+
"description": "API key for octopus deploy (required)"
77+
},
78+
"PROJECT": {
79+
"type": "string",
80+
"description": "The name of the project associated with this release (required)"
81+
},
82+
"NAME": {
83+
"type": "string",
84+
"description": "Name of the runbook to run (required)"
85+
},
86+
"ENVIRONMENTS": {
87+
"type": "array",
88+
"items": {
89+
"type": "string"
90+
},
91+
"description": "The environment names to run in (required)"
92+
},
93+
"VARIABLES": {
94+
"type": "array",
95+
"items": {
96+
"type": "string"
97+
},
98+
"description": "Set the value for a prompted variable in the format Label:Value (optional)"
99+
},
100+
"TENANTS": {
101+
"type": "array",
102+
"items": {
103+
"type": "string"
104+
},
105+
"description": "Run for these tenants (optional)"
106+
},
107+
"TENANT_TAGS": {
108+
"type": "array",
109+
"items": {
110+
"type": "string"
111+
},
112+
"description": "Run for tenants matching these tags (optional)"
113+
},
114+
"USE_GUIDED_FAILURE": {
115+
"type": "string",
116+
"description": "Enable Guided failure mode (true/false/default) (optional)"
117+
}
118+
}
119+
}
120+
returns: |-
121+
{
122+
"definitions": {},
123+
"$schema": "http://json-schema.org/draft-07/schema#",
124+
"type": "object",
125+
"additionalProperties": true,
126+
"patterns": [],
127+
"required": [
128+
"RUNBOOK_RUNS"
129+
],
130+
"properties": {
131+
"RUNBOOK_RUNS": {
132+
"type": "array",
133+
"description": "The list of runbook runs",
134+
"items": {
135+
"type": "object",
136+
"additionalProperties": true,
137+
"patterns": [],
138+
"required": [
139+
"RunbookRunId",
140+
"ServerTaskId"
141+
],
142+
"properties": {
143+
"RunbookRunId": {
144+
"type": "string",
145+
"description": "The runbook run Id"
146+
},
147+
"ServerTaskId": {
148+
"type": "string",
149+
"description": "The server task Id"
150+
}
151+
}
152+
}
153+
}
154+
}
155+
}
156+
stepsTemplate: |-
157+
run-runbook:
158+
name: octopusdeploy-run-runbook
159+
image: octopuslabs/octopus-cli
160+
tag: latest
161+
commands:
162+
- OUTPUT=$(octopus runbook run
163+
--project "[[.Arguments.PROJECT]]"
164+
--name "[[.Arguments.NAME]]"
165+
[[- range $val := .Arguments.ENVIRONMENTS ]] --environment "[[ $val ]]" [[ end ]]
166+
[[- range $val := .Arguments.VARIABLES ]] --variable "[[ $val ]]" [[ end ]]
167+
[[- range $val := .Arguments.TENANTS ]] --tenant "[[ $val ]]" [[ end ]]
168+
[[- range $val := .Arguments.TENANT_TAGS ]] --tenant-tag "[[ $val ]]" [[ end ]]
169+
[[- if .Arguments.USE_GUIDED_FAILURE ]] --guided-failure "[[ .Arguments.USE_GUIDED_FAILURE ]]" [[ end ]]
170+
--output-format json
171+
--no-prompt)
172+
- cf_export RUNBOOK_RUNS=$OUTPUT
173+
environment:
174+
- 'OCTOPUS_URL=[[.Arguments.OCTOPUS_URL]]'
175+
- 'OCTOPUS_API_KEY=[[.Arguments.OCTOPUS_API_KEY]]'
176+
- 'OCTOPUS_SPACE=[[.Arguments.OCTOPUS_SPACE]]'
177+
delimiters:
178+
left: "[["
179+
right: "]]"

0 commit comments

Comments
 (0)