Gitlab CI pipeline failing: a tag issue

8/23/2020

My gitlab CI pipeline is setup to run maven tests from a docker image created from my maven project.

I have tested the pipeline on my master branch and it worked fine and ran the test.

However I have created a new feature branch and now running the pipeline yet again, however I now get this error

error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: getting tag for destination: repository can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-./`: it2901/cs344-maven:feature/produce-allocation-pdf
ERROR: Job failed: command terminated with exit code 1

I can't seem to pinpoint the problem at all. I have also pushed the tag: tut3 to the feature branch as well.

Here is my .gitlab-ci.yml: https://controlc.com/7a94a00f

-- it2901
continuous-integration
kubernetes
pipe
yaml

1 Answer

8/23/2020

Based on what you shared, you have this configured:

VERSIONLABELMETHOD: "tut3" # options: "","LastVersionTagInGit"

It should be either:

VERSIONLABELMETHOD: ""

or

VERSIONLABELMETHOD: "LastVersionTagInGit"

or

VERSIONLABELMETHOD: "OnlyIfThisCommitHasVersion"

When you specify "tut3", the script takes it as if it was "" (empty string). Assuming you didn't define $VERSIONLABEL anywhere $ADDITIONALTAGLIST will also be empty.

And later in the code you can see that this gets executed:

if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then ADDITIONALTAGLIST="$ADDITIONALTAGLIST latest"; fi

Assuming $CI_DEFAULT_BRANCH is set to master if you use a separate branch mybranch the code above won't get executed so it's likely that the Kaniko command line doesn't have any a neither a valid $FORMATTEDTAGLIST or $IMAGE_LABELS.

You can debug by seeing their output on the script which is happening at the end before calling Kaniko:

...
echo $FORMATTEDTAGLIST
echo $IMAGE_LABELS
mkdir -p /kaniko/.docker
...

A hack would be to override $CI_DEFAULT_BRANCH with your custom branch.

✌️

-- Rico
Source: StackOverflow