Processing environment variables in SourceCraft
The SourceCraft CI/CD processes support environment variables. You can set the variables under the following items in the .sourcecraft/ci.yaml configuration file:
- Task: To provide the variables to all cubes linked to the task.
- Cube: To provide the variables to the specified cube.
Also, you can use predefined environment variables.
Warning
Do not store any sensitive data, such as passwords, access keys, or tokens, in environment variables; use secrets instead.
To use environment variables in CI/CD processes:
-
Configure CI/CD in your repository.
-
In the
.sourcecraft/ci.yamlconfiguration file, add the environment variables to thetasksorcubessection. Here is an example:workflows: my-workflow: # Here you define variables that will be available in all cubes # of all my-workflow tasks env: WORKFLOW_VAR: workflow-var tasks: - name: my-task # Here you define variables that will be available in all cubes # within my-task env: TASK_ENV_VAR: This variable is available in all cubes of this task. # Multi-line variable MULTILINE_VAR: | multi-var multi-var this is my multi-var cubes: - name: my-cube-1 # Here you define variables that will only be available # within my-cube-1 env: CUBE_ENV_VAR: This variable is available only in cube my-cube-1. # Variable with a value from a secret SECRET_VAR: ${{ secrets.<secret_name> }} script: - echo "$TASK_ENV_VAR" - echo "$MULTILINE_VAR" - echo "$CUBE_ENV_VAR" - echo "$SECRET_VAR" - echo "$WORKFLOW_VAR" - name: my-cube-2 # Here you define variables that will only be available # within my-cube-2 env: CUBE_ENV_VAR: This variable is available only in cube my-cube-2. script: - echo "$TASK_ENV_VAR" - echo "$CUBE_ENV_VAR" # Using a predefined variable - echo "$SOURCECRAFT_TASK" - echo "$WORKFLOW_VAR" - name: my-task-2 cubes: - name: my-cube-3 script: - echo "$WORKFLOW_VAR" -
Push changes to a remote repository.
-
Check the CI/CD process.
See also
Was the article helpful?
Previous