1

I have a laravel app that I'm trying to deploy to Google Kubernetes with GitLab autodevops. When I trigger the CI pipeline it starts Herokuish PHP build and npm install, however, some of the composer repos are private. I understand that I need to add an environment variable named COMPOSER_AUTH that contains the content of auth.json that contains tokens to allow retrieving from the repos. But for some reason, the pipeline is always failing because it did not have permission to retrieve those repos. I know that the content of auth.json is correct because I tried it locally and it worked. I hope that someone helps me resolve this issue!

Here is what I have in the repo section in composer.json

"repositories": {
   "nova" : {
      "type": "composer",
      "url": "https://nova.laravel.com"
   }
}

For the COMPOSER_AUTH variable, the content looks like this

'{
    "gitlab-token":{
        "gitlab.com": "GITLABTOKENHERE"
    },
    "http-basic": {
        "nova.laravel.com": {
            "username": "MY-EMAILI-HERE",
            "password": "MY-NOVA-TOKEN-HERE"
        }
    }
}'

And this is some of the error message I get during npm install enter image description here

Nidhal Abidi
  • 105
  • 1
  • 6

1 Answers1

0

Not sure if you're still having this issue, but I came across this myself. It has been a huge pain to deal with but I just got it sorted out. I am using a Gitlab pipeline with Dokku, so it sounds like we're doing something similar.

In GitLab Project > Settings > CI/CD > Variables I created a variable called COMPOSER_AUTH. The formatting for this was tricky to figure out though. All the examples I found online were different so there was a lot of trial and error. Here is an example of what I did.

Key: COMPOSER_AUTH 

Value: '{"http-basic":{"nova.laravel.com":{"username":"youremail","password":"yourpassword"}}}'

Type: Variable

So, the trick was to add single quotes wrapping the json and then remove all spaces so it's all just on one line without white space.

From there I was able to reference the Gitlab CI variable using $COMPOSER_AUTH and save it to my .env in the pipeline.