mvisonneau / gitlab-ci-pipelines-exporter

Prometheus / OpenMetrics exporter for GitLab CI pipelines insights
Apache License 2.0
1.29k stars 243 forks source link

404 when trying to get branches #392

Open mseiwald opened 2 years ago

mseiwald commented 2 years ago

Hello,

I'm trying to use this exporter with the following config:

cat <<EOF > $(pwd)/config.yml
gitlab:
  url: https://mygitlab.domain
  token: XXXXX
wildcards:
  - owner:
      name: mygroup
      kind: group
      include_subgroups: true
EOF

and running with this command:

docker run -it --rm \        
   --name gitlab-ci-pipelines-exporter \
   -v $(pwd)/config.yml:/etc/config.yml \    
   -p 8080:8080 \                  
   mvisonneau/gitlab-ci-pipelines-exporter:latest \
   run --config /etc/config.yml

Log Snippet:

INFO[2022-01-19T13:49:03Z] discovered new project                        project-name=mygroup/subgroup1/myproject wildcard-archived=false wildcard-owner-include-subgroups=true wildcard-owner-kind=group wildcard-owner-name=mygroup wildcard-search=
WARN[2022-01-19T13:49:05Z] pulling refs from project                     error="GET https://mygitlab.domain/api/v4/projects/mygroup/subgroup1/myproject/repository/branches: 404 {error: 404 Not Found}" project-name=mygroup/subgroup1/myproject

As can be seen it discovers subgroups and projcets fine. But then it's getting a 404 when trying to get the branches for each project. From my pov the URL https://mygitlab.domain/api/v4/projects/mygroup/subgroup1/myproject/repository/branches is wrong. Instead it should be https://mygitlab.domain/api/v4/projects/:id/repository/branches as per the docs.

Can someone help out?

mvisonneau commented 2 years ago

can you share the version of GitLab & the exporter you are using? 🤔

mseiwald commented 2 years ago

@mvisonneau

Gitlab: 14.7.0-ee Exporter: v0.5.2

acericdev commented 2 years ago

hello @mseiwald, did you find a fix for that issue ? thank you ! :)

mseiwald commented 2 years ago

hello @mseiwald, did you find a fix for that issue ? thank you ! :)

Unfortunately no.

acuntex commented 6 months ago

The gitlab api either supports a numeric id or the project path (urlencoded) https://mygitlab.domain/api/v4/projects/mygroup/subgroup1/myproject/repository/branches should be actually: https://mygitlab.domain/api/v4/projects/mygroup%2Fsubgroup1%2Fmyproject/repository/branches

mygroup/subgroup1/myproject -> mygroup%2Fsubgroup1%2Fmyproject

@mvisonneau Is a urlencode possible when creating the url?