How To: Automate creation of Shared Secrets for pipelines

This articles describes how to manage secrets across different pipelines in an efficient manner.

Script for create secret context

The script reads each line from the provided file and appends it to the Codefresh create context secret command.
This results in a single command that creates a secret context with all the specified secrets.

Ensure you have the necessary permissions to create contexts in Codefresh.


CMD="codefresh create context secret <secret_context_name>"

while read LINE; do

CMD="${CMD} -v ${LINE}"

done < "$1"

echo "$CMD"

How to use the script

  1. Prepare the list of your secrets.
    Start by preparing a file containing your secrets.
    Each line in the file should contain one secret in the format KEY=VALUE.

  2. Set execution permissions.
    Make the script executable by running:
    chmod +x

  3. Run the script with the command:
    ./ secret_list.txt
    where: secret_list.txt is the file containing your secrets

  4. Verify creation.
    After executing the script, verify that the secret context has been created in Codefresh with the specified secrets.

Secrets in pipelines
Configuring access control for pipelines
Pipeline execution context