To extract the basePath and tag values generated inside /workspace/source/helm/build-values.yaml during the helm-chart-publish step and export them to your shell environment or a subsequent process, you can use a short Bash script snippet right after that step finishes.
Here is a concrete procedure using standard parsing tools:
Step-by-Step Shell Procedure
Option A: Using yq (Recommended for YAML parsing)
If yq is available in your container environment, it cleanly parses the nested YAML structure shown in the logs:
# Define the path to the generated file shown in your logs
YAML_FILE="/workspace/source/helm/build-values.yaml"
# 1. Extract the variables using yq
EXTRACTED_BASE_PATH=$(yq eval '.containerImages.basePath' "$YAML_FILE")
EXTRACTED_TAG=$(yq eval '.containerImages.tag' "$YAML_FILE")
# 2. Export them to the shell environment
export DOCKER_BASE_PATH="$EXTRACTED_BASE_PATH"
export DOCKER_TAG="$EXTRACTED_TAG"
# 3. Verify they are exported
echo "Successfully exported basePath: $DOCKER_BASE_PATH"
echo "Successfully exported tag: $DOCKER_TAG"
Option B: Using grep and awk (No external dependencies)
If yq is not installed in your CI/D execution image, you can extract the values using standard text-processing utilities:
YAML_FILE="/workspace/source/helm/build-values.yaml"
# Extract the first match for basePath and tag
EXTRACTED_BASE_PATH=$(grep 'basePath:' "$YAML_FILE" | head -n 1 | awk '{print $2}')
EXTRACTED_TAG=$(grep 'tag:' "$YAML_FILE" | head -n 1 | awk '{print $2}')
# Export to environment
export DOCKER_BASE_PATH="$EXTRACTED_BASE_PATH"
export DOCKER_TAG="$EXTRACTED_TAG"
echo "Exported basePath: $DOCKER_BASE_PATH"
echo "Exported tag: $DOCKER_TAG"
Passing to Downstream Pipeline Steps
If you need these variables to persist across different steps in your CI runner (such as Tekton or GitHub Actions):
-
Tekton: Write them to results files (
echo -n "$EXTRACTED_TAG" > $(results.tag.path)). -
GitHub Actions: Write them to the environment file (
echo "DOCKER_TAG=$EXTRACTED_TAG" >> $GITHUB_ENV).
Top comments (0)