Skip to content

Commit 0cc3b85

Browse files
authored
Files documentation update. (#5)
1 parent 7d8f36f commit 0cc3b85

File tree

4 files changed

+115
-2
lines changed

4 files changed

+115
-2
lines changed

source/pages/pipelines/building_failure_handlers.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,31 @@ Below is an example of running a :attr:`failure handlers<FailureHandler>` from b
8181
.. note::
8282
Notice that ``failure-handler-1`` will run twice because it's declared in both the global section and in the step. Currently IceCI does not implement any deduplication mechanism for failure handlers.
8383

84+
85+
Environment variables and files
86+
_______________________________
87+
88+
Here's an example of defining environment variables and files on :attr:`failure handler<FailureHandler>` level.
89+
90+
.. code-block:: yaml
91+
92+
steps:
93+
- name: step-that-fails
94+
dockerRun:
95+
image: busybox
96+
script: "noSuchCommand"
97+
onFailure:
98+
- handlerName: failure-handler-1
99+
100+
failureHandlers:
101+
- name: failure-handler-1
102+
image: busybox
103+
script: |
104+
echo $ICE_FH
105+
cat /mnt/file
106+
environment:
107+
- name: ICE_FH
108+
value: failure-handler-env
109+
files:
110+
- path: /mnt/file
111+
fromSecret: failure-secret

source/pages/pipelines/building_globals.rst

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ Some of the settings that can be specified for :attr:`steps<Step>` can also be s
1717
Examples
1818
++++++++
1919

20-
Below is an example of setting up a :attr:`global<globals>` environment variables, and overriding them on :attr:`step<Step>` level.
20+
Environment variables
21+
_____________________
22+
23+
Below is an example of setting up a :attr:`global<globals>` environment variables and overriding them on :attr:`step<Step>` level.
2124

2225
.. code-block:: yaml
2326
@@ -40,3 +43,28 @@ Below is an example of setting up a :attr:`global<globals>` environment variable
4043
- name: GLOBAL_ENV
4144
value: local-value
4245
46+
Files
47+
_____
48+
49+
Here's an example of setting up a :attr:`global<globals>` file and overriding it on :attr:`step<Step>` level.
50+
51+
.. code-block:: yaml
52+
53+
globals:
54+
files:
55+
- path: /mnt/file
56+
fromSecret: global-secret
57+
58+
steps:
59+
- name: step1
60+
dockerRun:
61+
image: busybox
62+
script: "cat /mnt/file"
63+
64+
- name: step2
65+
dockerRun:
66+
image: busybox
67+
script: "cat /mnt/file"
68+
files:
69+
- path: /mnt/file
70+
fromSecret: local-secret

source/pages/pipelines/building_steps.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ Here's an example of passing environment variables to a container.
8484

8585
As you can see, the environment variable value is hardcoded into the pipeline. This is fine if your build configuration doesn't contain passwords or other sensitive data. For more information on how to manage sensitive data in ``IceCI`` see :ref:`secrets section<secrets-desc>`.
8686

87+
Files
88+
_____
89+
90+
Here's an example of mounting files from a secret in a container.
91+
92+
.. code-block:: yaml
93+
94+
steps:
95+
- name: file-test
96+
dockerRun:
97+
image: busybox
98+
script: "cat /mnt/file"
99+
files:
100+
- path: /mnt/file
101+
fromSecret: file-secret
102+
103+
.. note::
104+
105+
The content of a file can't be defined inline. Every file has to have a reference to a secret, from which the content is pulled.
106+
107+
108+
87109
Further reading
88110
+++++++++++++++
89111

source/pages/pipelines/structure.rst

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ The root of pipeline yaml file consists of the following fields.
6767
Those environment variables will be passed to every :attr:`Docker run step<DockerRun>` in the pipeline.
6868

6969
.. important::
70-
``Failure handlers`` have access to all the environment variables of a given ``step`` injected into their spec, so they're available in the failure handler as well. For more information about passing environment variables to failure handlers see TODO
70+
``Failure handlers`` have access to all the environment variables of a given ``step`` injected into their spec, so they're available in the failure handler as well.
71+
72+
.. py:attribute:: files
73+
:type: list(File)
74+
75+
List of files that will be mounted in every :attr:`Docker run step<DockerRun>` in the pipeline.
76+
77+
.. important::
78+
Like environment variables, files from a given ``step`` are also mounted into ``Failure handlers``.
7179

7280

7381

@@ -143,6 +151,11 @@ Definitions of all objects and types used in the pipeline definition.
143151

144152
List of environment variables passed to the container.
145153

154+
.. py:data:: files
155+
:type: list(File)
156+
157+
List of files that will be mounted in the container.
158+
146159

147160

148161
.. _docker-build-reference:
@@ -261,6 +274,11 @@ Definitions of all objects and types used in the pipeline definition.
261274

262275
List of environment variables passed to the container.
263276

277+
.. py:data:: files
278+
:type: list(File)
279+
280+
List of files that will be mounted in the container.
281+
264282

265283
.. _failure-handler-reference-reference:
266284

@@ -296,3 +314,20 @@ Definitions of all objects and types used in the pipeline definition.
296314

297315
.. note::
298316
Currently ``IceCI`` supports creating environment variables by explicitly entering their values in the pipeline yaml or by providing a secret name from which the value should be taken. Those options are exclusive for a given variable - you can't have both :attr:`value` and :attr:`fromSecret` set at the same time - the pipeline validation will fail.
317+
318+
319+
320+
.. _file-reference:
321+
322+
.. py:attribute:: File
323+
:type: Object
324+
325+
The file object represents a file that'll be mounted in a container from a secret. Unlike environment variables, file values cannot be provided inline - they have to reference a secret.
326+
327+
.. py:attribute:: path
328+
329+
The absolute path that the file will be mounted in.
330+
331+
.. py:attribute:: fromSecret
332+
333+
Name of a secret from which the value should be retrieved to mount into the container as a file.

0 commit comments

Comments
 (0)