semantic-release / github

:octocat: semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues
MIT License
402 stars 125 forks source link

http proxy is not working on Openshift #696

Open USI-KMD opened 1 year ago

USI-KMD commented 1 year ago

Creating GitHub release is failing when semantic-release is executed on an Openshift behind a corporate proxy. When working on an Openshift clusters without a proxy the same configuration works fine. Also, the corporate proxy works fine in all other cases.

I tried configuring the proxy using HTTP_PROXY and HTTPS_PROXY environment variables and via the following .releaserc config:

{
  "branches": [
    "+([0-9])?(.{+([0-9]),x}).x",
    {
      "name": "main",
      "prerelease": false
    }
  ],
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "angular"
      }
    ],
    "@semantic-release/changelog",
    [
      "@semantic-release/github",
      {
        "proxy": {
          "host": "XXXXX [redacted]",
          "port": 3128,
          "secureProxy": false
        }
      }
    ]
  ]
}

However, in all cases I'm getting the following error:

2023-09-11T12:53:48.405Z semantic-release:get-git-auth-url Verifying ssh auth by attempting to push to  https://git:[secure]@github.com/XXXXX.git
2023-09-11T12:53:51.494Z semantic-release:get-tags found tags for branch main: []
2023-09-11T12:53:51.503Z semantic-release:get-tags found tags for branch test-sem-ver-proxy: []
[12:53:51 PM] [semantic-release] › ✔  Run automated release from branch test-sem-ver-proxy on repository https://git:[secure]@github.com/XXXXXX.git
[12:53:51 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[12:53:51 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/exec"
[12:53:51 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/exec"
[12:53:51 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[12:53:51 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[12:53:51 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/github"
[12:53:51 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication
[12:54:46 PM] [semantic-release] › ✘  Failed step "verifyConditions" of plugin "@semantic-release/github"
[12:54:46 PM] [semantic-release] › ✘  An error occurred while running semantic-release: RequestError [HttpError]: fetch failed
    at /usr/local/lib/node_modules/@semantic-release/github/node_modules/@octokit/request/dist-node/index.js:136:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async requestWithGraphqlErrorHandling (/usr/local/lib/node_modules/@semantic-release/github/node_modules/@octokit/plugin-retry/dist-node/index.js:71:20)
    at async Job.doExecute (/usr/local/lib/node_modules/@semantic-release/github/node_modules/bottleneck/light.js:405:18) {
  status: 500,
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/XXXXXX',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': '@semantic-release/github v9.0.5 octokit-core.js/5.0.0 Node.js/18.17.1 (linux; x64)',
      authorization: 'token [REDACTED]'
    },
    request: {
      agent: [HttpsProxyAgent],
      hook: [Function: bound bound register],
      retryCount: 3,
      retries: 3,
      retryAfter: 16
    }
  },
  pluginName: '@semantic-release/github'
}
AggregateError: 
    HttpError: fetch failed
        at /usr/local/lib/node_modules/@semantic-release/github/node_modules/@octokit/request/dist-node/index.js:136:11
        at async requestWithGraphqlErrorHandling (/usr/local/lib/node_modules/@semantic-release/github/node_modules/@octokit/plugin-retry/dist-node/index.js:71:20)
        at async Job.doExecute (/usr/local/lib/node_modules/@semantic-release/github/node_modules/bottleneck/light.js:405:18)
    at file:///usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:55:13
    at async pluginsConfigAccumulator.<computed> [as verifyConditions] (file:///usr/local/lib/node_modules/semantic-release/lib/plugins/index.js:87:11)
    at async run (file:///usr/local/lib/node_modules/semantic-release/index.js:106:3)
    at async Module.default (file:///usr/local/lib/node_modules/semantic-release/index.js:275:22)
    at async default (file:///usr/local/lib/node_modules/semantic-release/cli.js:55:5) {
  errors: [
    RequestError [HttpError]: fetch failed
        at /usr/local/lib/node_modules/@semantic-release/github/node_modules/@octokit/request/dist-node/index.js:136:11
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async requestWithGraphqlErrorHandling (/usr/local/lib/node_modules/@semantic-release/github/node_modules/@octokit/plugin-retry/dist-node/index.js:71:20)
        at async Job.doExecute (/usr/local/lib/node_modules/@semantic-release/github/node_modules/bottleneck/light.js:405:18) {
      status: 500,
      request: [Object],
      pluginName: '@semantic-release/github'
    }
  ]
}

Is there an error in my configuration? Otherwise, I would greatly appreciate any help with further troubleshooting.

UDWSU1 commented 10 months ago

@USI-KMD Have you figured it out. Dealing with similar issue.

travi commented 10 months ago

open to a PR to improve documentation or suggestion for a fix if there is a problem with the current implementation, but could use help investigating this. i have no environment to test this scenario from. if someone could provide a public reproduction, that could be a place to start

channon4 commented 10 months ago

I also am finding that proxy settings are not respected. I can reproduce locally while on/off our corporate VPN.

I dont know how to set up a proxy quickly but the easiest way to tell there is an issue is by setting the proxy environment variables to random values and see that it still works which it shouldnt.

export HTTPS_PROXY=http://internet.x.com:4444
export HTTP_PROXY=http://internet.x.com:4444
npm config set proxy http://internet.x.com:4444
npm config set https-proxy http://internet.x.com:4444

This url is fake so we should expect semantic release to fail but yet it works

travi commented 9 months ago

likely related: https://github.com/octokit/request.js/issues/577

dashuaige2000 commented 2 months ago

I also have the same mistake, proxy IP is an internal network

vmorales-2920 commented 3 weeks ago

Facing same issues, have you found a solution?