Codium pr agent integration in gitlab pipeline

:hugs: Please help fill in this template with all the details to help others help you more efficiently. Use formatting blocks for code, config, logs and ensure to remove sensitive data.

Problem to solve

we have self hosted gitlab and trying to add codium pr agent yml pipeline , the problem is in runner/config.toml file , the admin not ready to change the previlege to true , so , i have to find alternative to create pipeline , u have created it , but im getting the error

  • *stages:
    • pr_review

pr_agent_job:
stage: pr_review
image: codiumai/pr-agent:latest # Use the specific Docker image designed for the PR Agent
script:
- python cli.py --openai-api-key $OPENAI_KEY --pr-url=“${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}” review
only:
- merge_requests
variables:
GITLAB_TOKEN: $GITLAB_PR_AGENT_PAT # Personal Access Token for the GitLab API
GITLAB_URL: “self hosted gitlab link” # Your self-hosted GitLab URL
*


*

Steps to reproduce

Which troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

Configuration

Add the CI/CD configuration from .gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml). Alternatively, create a public GitLab.com example project that provides all necessary files to reproduce the question.

Versions

Please select whether options apply, and add the version information.

  • [ +] Self-managed
  • GitLab.com SaaS
  • [+ ] Self-hosted Runners

Versions

Helpful resources

Thanks for taking the time to be thorough in your request, it really helps! :blush:

Hi,

I believe the issue is that the image’s entrypoint is not /bin/bash (or /bin/sh), but the cli command (see dockerfile).

Try overriding the image entrypoint like this (and adjusting the cli invocation if needed):

pr_agent_job:
  stage: pr_review
  image: 
    name: codiumai/pr-agent:latest
    entrypoint: [""]
  script:
    - python /app/pr_agent/cli.py --openai-api-key $OPENAI_KEY --pr-url=“${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}” review
  only:
    - merge_requests
Thanks for responding for my issue.
I just currently setup environment variable to gitlab 
and creating following yml
I have tried this one though , getting the following issue , I have attached in screen shot.
current modification
stages:
  - build
  - pr_review

pr_agent_job:
  stage: pr_review
  image: 
    name: codiumai/pr-agent:latest
    entrypoint: [""]
  script:
    - python /app/pr_agent/cli.py --openai-api-key "$OPENAI_KEY" --pr-url="${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}" review
  only:
    - merge_requests
  variables:
    OPENAI_KEY: $OPENAI_KEY
    CI_PROJECT_URL: $CI_PROJECT_URL
    CI_MERGE_REQUEST_IID: $CI_MERGE_REQUEST_IID

!

Hi,

Okay. So now the issue is obviously just the invocation of the command itself. The --openai-api-key "$OPENAI_KEY" must come after the review, as it’s stated by the help hint. So perhaps try the following:

python /app/pr_agent/cli.py --pr-url="${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}" review --openai-api-key "$OPENAI_KEY"

If that does not work as expected, you should consult the documentation of the Codium PR Agent CLI.

Yeah, I even tried your suggestion, but it didn’t work. For the self-hosted GitLab, I created a pipeline for the PR agent, but the documentation lacks sufficient detail and there is no proper direction.

I have set this up this way:

codium-review:
  image:
    name: codiumai/pr-agent:latest
    entrypoint: ["/bin/bash"]
  variables:
    GIT_STRATEGY: none
  script:
    - env CONFIG.GIT_PROVIDER="gitlab" OPENAI.KEY="$CODIUM_OPENAI_API_KEY" GITLAB.PERSONAL_ACCESS_TOKEN="$GITLAB_PAT" GITLAB.URL="$CI_SERVER_URL" python /app/pr_agent/cli.py --pr_url "${CI_MERGE_REQUEST_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}" review