You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/configuration/functions/basics.mdx
+31-5Lines changed: 31 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,36 @@ import GlobalFunctionRef from '../_partials/functions/reference_global.mdx'
11
11
Functions are bash functions that can be called inside the remainder of `devspace.yaml`. A common use case is to define reusable functionality that is called from within the scripts you specify within the `pipelines` section.
12
12
13
13
There are two types of functions:
14
-
1.[Custom Functions](#built-in-functions) defined in `devspace.yaml` (often added via [`imports`](../imports/basics.mdx))
15
-
2.[Built-In Functions](#built-in-functions)
14
+
1.[Custom Functions](#custom-functions) defined in `devspace.yaml` (often added via [`imports`](../imports/basics.mdx))
15
+
2.[Built-In Functions](#built-in-functions) such as `build_images` or `create_deployments`
16
16
17
-
## Workflow
18
17
19
-
### 1. Define Functions
20
-
<ConfigPartial/>
18
+
## Custom Functions
19
+
DevSpace provides support for custom functions. To use them, you need to:
20
+
1. Declare your custom functions within the `functions` section of `devspace.yaml`
21
+
2. Call custom functions from any scripted field in `devspace.yaml` such as in `pipelines` or in any value defined using an inline script such as `$(command)`
22
+
23
+
### 1. Declare Functions
24
+
Declaring a function means adding a key with the function name to the `functions` section in `devspace.yaml` as shown in the example below:
25
+
```yaml
26
+
functions:
27
+
hello_world: |-
28
+
echo "Hello World"
29
+
get_tag: |-
30
+
echo $(git rev-parse --short HEAD)
31
+
```
21
32
22
33
### 2. Call Functions
34
+
To call a custom function
35
+
```yaml
36
+
pipelines:
37
+
deploy: |-
38
+
build_images --tag $(get_git_commit)
39
+
create_deployments --all
40
+
dev: |-
41
+
hello_world
42
+
run_default_pipeline
43
+
```
23
44
24
45
25
46
## Built-In Functions
@@ -37,3 +58,8 @@ Pipeline-only functions can only be used inside the scripts within the `pipeline
37
58
Global functions can be used anywhere in `devspace.yaml`, either in config fields that expect a bash script such as within `functions` or using [`$(command)` vars](../variables/command.mdx) in any other config field.
0 commit comments