Skip to content

Commit cbdc5c2

Browse files
Global environment variables in the Codefresh runner
1 parent 5cf38db commit cbdc5c2

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

_docs/administration/codefresh-runner.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,59 @@ codefresh attach runtime --agent-name $AGENT_NAME --agent-kube-namespace codefre
378378

379379
You can fine tune the installation of the runner to better match your environment and cloud provider.
380380

381+
### Custom global environment variables
382+
383+
You can add your own environment variables in the runtime environment, so that all pipeline steps have access to the same set of external files. A typical
384+
example would be a shared secret that you want to pass everywhere.
385+
386+
To get a list of all available runtimes execute:
387+
388+
```
389+
codefresh get runtime-environments
390+
```
391+
392+
Choose the runtime that you want to modify and get its yaml representation:
393+
394+
```
395+
codefresh get runtime-environments ivan@acme-ebs.us-west-2.eksctl.io/codefresh-runtime -o yaml > runtime.yaml
396+
```
397+
398+
Under the `runtimeScheduler` block you can add an additional element with names `userEnvVars` that follows the same syntax as [secret/environment variables](https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables)
399+
400+
`runtime.yaml`
401+
{% highlight yaml %}
402+
{% raw %}
403+
runtimeScheduler:
404+
type: KubernetesPod
405+
imagePullPolicy: Always
406+
cluster:
407+
namespace: codefresh
408+
clusterProvider:
409+
accountId: 5c1658d1736122ee1114c842
410+
selector: docker-desktop
411+
serviceAccount: codefresh-engine
412+
envVars:
413+
LOGGER_LEVEL: debug
414+
NODE_ENV: kubernetes
415+
NODE_TLS_REJECT_UNAUTHORIZED: '0'
416+
DISABLE_WORKSPACE_CACHE: 'true'
417+
NO_EXT_MONITOR: 'true'
418+
userEnvVars:
419+
- name: SPECIAL_LEVEL_KEY
420+
valueFrom:
421+
secretKeyRef:
422+
name: dev-db-secret
423+
key: username
424+
{% endraw %}
425+
{% endhighlight %}
426+
427+
Update your runtime environment with the [patch command](https://codefresh-io.github.io/cli/operate-on-resources/patch/):
428+
429+
```
430+
codefresh patch runtime-environment ivan@acme-ebs.us-west-2.eksctl.io/codefresh-runtime -f runtime.yaml
431+
```
432+
433+
381434

382435
### Custom volume mounts
383436

_docs/whats-new/whats-new.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ toc: true
1818
- SonarQube Plugin - [documentation]({{site.baseurl}}/docs/testing/sonarqube-integration/)
1919
- GitOps deployments - [documentation]({{site.baseurl}}/docs/ci-cd-guides/gitops-deployments/)
2020
- Global volume mounts in the Codefresh runner - [documentation]({{site.baseurl}}/docs/administration/codefresh-runner/#custom-volume-mounts)
21+
- Global environment variables in the Codefresh runner - [documentation]({{site.baseurl}}/docs/administration/codefresh-runner/#custom-global-environment-variables)
2122

2223
### October 2020
2324

0 commit comments

Comments
 (0)