Use repository name in travis CI

Asked by At

I am facing an issue on Travis CI. I seem not to be able to use the repository name as an environment variable.

I have a Travis build that is setup to build, tag and push a Docker image.

In the after_success section of the .travis.yml file the following command is running

docker build -t ${PROJECT}:${TRAVIS_BRANCH} .

(The environment variable ${PROJECT} is the actual name of the repository and is set in the repository settings.)

The problem is that Docker is using "[secure]" as image name instead of the repository name. I end up with something like

Successfully tagged [secure]:staging

After that when I am tagging the image the following error is returned

Error parsing reference: "/[secure]:staging" is not a valid repository/tag: invalid reference format

I have tried to update ${PROJECT} to a random string and it worked fine.

Is there a way to use the repository name as a environment variable?

1 Answers

andig On

It seems as if your $PROJECT contains a leading slash which might be the problem.