Search code examples
gitlabgitlab-ci

How to add an external URL to the proxy


I am having an issue with a test run being stuck via a GitLab pipeline, though it does work when I run my test locally. I have found the common issue which is it gets stuck when trying to call an external URL.

Example url: https://api.us.cajama.com/v3.6

From what I have heard, it might need to be added to the proxy, but I am not sure how to do that. Can someone direct me in adding this URL to the proxy so GitGab have access to this external service?

Is it a change in the gitlab-ci.yml file or something else?


Solution

  • You need to configure your proxy settings

    Add your environment variable to gitlab-ci.yml

    variables:
      http_proxy: http://your-proxy-server:proxy-port
      https_proxy: http://your-proxy-server:proxy-port
      no_proxy: "localhost,127.0.0.1,api.us.cajama.com"
    

    Add this proxy settings to your job that requires access to the external URL

    stages:
      - test
        test-job:
          stage: test
          script:
            - echo "Running tests"
            - export http_proxy="http://your-proxy-server:proxy-port"
            - export https_proxy="http://your-proxy-server:proxy-port"
            - export no_proxy="localhost,127.0.0.1,api.us.cajama.com"
            - your-test-command
    

    You can fill the placeholders with your own record