Build V2 - CF_BRANCH_TAG_NORMALIZED Error

I am trying out the new V2 build step with registry tagging support and following the examples in the docs (Deprecation of the Codefresh Container Registry · Codefresh | Docs). Example from docs:

    type: build
    stage: build
    image_name: my-docker-image
    tags:
      - latest
      - ${{CF_BRANCH_TAG_NORMALIZED}}
      - v1.1

Trying to use CF_BRANCH_TAG_NORMALIZED to tag the image, but the value is the full NOT-normalized form, which is causing the following error:

invalid argument "myimagename:feature/JIRA-1234_codefreshdeploys" for "-t, --tag" flag: invalid reference for mat

That variable worked fine before with our separate image push steps.

As a workaround, using disable_push: true in the build step and using a the push step with CF_BRANCH_TAG_NORMALIZED works.

Thanks! I’ve got a bug logged for this so we’ll let you know once it’s sorted out. :slight_smile:

1 Like

Hello

We have investigated this. Apparently there are some docker registries that accept tags with capital letters and some do not. Your registry seems to be the latter.

You can use instead the variable CF_BRANCH_TAG_NORMALIZED_LOWER_CASE to make sure that the final result is compliant with your registry.

Just to be on the safe side, I also updated the docs to use the lower case variable instead of the CF_BRANCH_TAG_NORMALIZED variable (which will not tamper with case)

This has nothing to do with capitalization. The problem is that CF_BRANCH_TAG_NORMALIZED behavior has changed in the V2 of the build step. In other places the value of that variable removes any offending characters like /, which is the cause of my error. As it is right now, there is no difference between CF_BRANCH_TAG_NORMALIZED and CF_BRANCH.

I can use CF_BRANCH_TAG_NORMALIZED without error in push image steps and other places. It is only in the new v2 build step that it is not normalizing the branch name.

Hey there Darren.

Nothing was changed in the value of CF_BRANCH_TAG_NORMALIZED env var when moving to build V2.

Can you please share link to the build/s that shows this behavior of both the build and the push steps so we can check and better understand the issue you are having?

Thanks.

Here is a link to the broken build: Codefresh | console

Here is the relevant yaml snippet:

  build_dockerfile:
    title: Building Dockerfile
    stage: build
    type: build
    buildkit: true
    image_name: ${{PROJECT_NAME_LOWER}}
    working_directory: services/${{PROJECT_NAME}}
    dockerfile: Dockerfile
    target: production
    build_arguments:
      - PROJECT_NAME=${{PROJECT_NAME}}
    registry: gcr
    tags:
      - latest
# Invalid tag error triggered here (tag still includes / in branch name)
      - ${{CF_BRANCH_TAG_NORMALIZED}}
      - ${{CF_SHORT_REVISION}}
  push_docker_file:
    title: Pushing image to Google Docker registry
    stage: build
    type: push
    candidate: ${{build_dockerfile}}
# Correct tag here (tag has / in branch name removed)
    tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
    registry: gcr