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:

  1. Configure CI/CD in your repository.

  2. In the .sourcecraft/ci.yaml configuration file, add the environment variables to the tasks or cubes section. Here is an example:

    tasks:
      - name: my-task
        # Defines the variables to go to all the cubes associated with the task.
        env:
          TASK_VAR: test-var-'test'-\"test\"
          MULTILINE_VAR: |
            multi-var
            multi-var
            this is my multi-var
    
        cubes:
          - name: my-cube
            # Defines the variables to go only to a specific cube.
            env:
              CUBE_VAR: "you can see me here only"
              SECRET_VAR: ${{ secrets.<secret_name> }}
            script:
              - echo "$TASK_VAR"
              - echo "$MULTILINE_VAR"
              - echo "$CUBE_VAR"
              - echo "$SECRET_VAR"
    
  3. Push changes to a remote repository.

  4. Check the CI/CD process.

See also