GoogleCloudPlatform / GoogleCloudPlatform/cloud-builders-community

How to replace slashes in the branch name

Open
#184 10 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.3k
Forks
848
PR merge metrics
No merged PRs in 30d

Description

Git branches uses names like `feature/new-feature`, the slash is incompatible with docker image tags so i want to use a regex (or other means) to replace the slash in the $BRANCH_NAME with an underscore. This is possible in bash using the following:

```
BRANCH_NAME=feature/test echo ${BRANCH_NAME/\//_}
```

is there any way to create an env variable with the branch name escaped in cloudbuild.yaml?

Contributor guide

Open the contributing guide

Research direction

Start with the cloudbuild.yaml configuration and the documented handling of the $BRANCH_NAME environment variable. Check whether the requested slash-to-underscore transformation can be represented there, using the bash example and Docker image-tag requirement as the acceptance criteria. Done means the branch-derived value is available as an environment variable without slashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, docker, gcp
Domain
build-system, cloud
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.