Skip to content
  • Arnaud Rebillout's avatar
    Use CI_COMMIT_REF_SLUG to derive image tag from branch name · 29a1be62
    Arnaud Rebillout authored
    When development of salsa-ci-pipeline is done on a branch, the images
    are tagged according to `CI_COMMIT_REF_NAME`. However the set of
    characters allowed for a git ref name is wider than the set of
    characters allowed for a image tag, so some branch names fail the
    pipeline. For example, with a branch named `wip/apt-details`:
    
    ```
    $ buildah build [...]
    Error: tag base:sid_wip/apt-details: invalid reference format
    ```
    
    The `/` is a commonly-used character in Git branch names (I personally
    use it all the time), but it's not the only one, eg. `+` or `@` are
    allowed in git branch names, but will fail the pipeline all the same.
    
    It looks like the set of characters allowed for a image tag is defined
    at <https://docs.docker.com/reference/cli/docker/image/tag/>:
    
    > The tag must be valid ASCII and can contain lowercase and uppercase
    > letters, digits, underscores, periods, and hyphens.
    
    It turns out that GitLab already has a pre-defined variable that fits
    the bill, named `CI_COMMIT_REF_SLUG`, defined as such:
    
    > `CI_COMMIT_REF_NAME` in lowercase, shortened to 63 bytes, and with >
    > everything except `0-9` and `a-z` replaced with `-`. No leading /
    > trailing `-`.  Use in URLs, host names and domain names.
    
    IMO, better make use of `CI_COMMIT_REF_SLUG` and make it easier for
    contributors.
    29a1be62
After you've reviewed these contribution guidelines, you'll be all set to contribute to this project.
Loading