Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBranches does not use git auth url #1170

Closed
dotfold opened this issue May 1, 2019 · 8 comments
Closed

getBranches does not use git auth url #1170

dotfold opened this issue May 1, 2019 · 8 comments

Comments

@dotfold
Copy link

dotfold commented May 1, 2019

Current behavior

I'm running semantic-release in a node:11 docker container, with GL_URL and GL_TOKEN values provided.

During the setup phase after verify(context), getBranches is then called which eventually results in the invocation of the git command git ls-remote --heads origin. This is made without any auth and results in an authentication error from the remote.

I've followed the code path through, and the command is invoked in lib/branches/expand.js

Should getGitAuthUrl be run first, and then the options.repositoryUrl be passed through to getBranches and subsequently also the call to fetch in lib/branches/index?

I've added that change in locally and getBranches works when using the gitAuthUrl instead of origin.

I'd be happy to submit a PR if this approach is valid.

Expected behavior

There should not be an authentication error when a token is supplied.

Environment

  • semantic-release version: 16.0.0-beta.18
  • CI environment: docker
  • Plugins used:
  • semantic-release configuration:
---
branches:
  - master
  - name: next
    prerelease: 'rc'
  - name: beta
    prerelease: 'beta'
plugins:
  - '@semantic-release/commit-analyzer'
  - '@semantic-release/release-notes-generator'
  - '@semantic-release/gitlab'
success: false
fail: false
  • CI logs:

Note: this is running in a node:11 docker container.

root@94e0a71c0f6d:/src# GL_URL=<REDACTED> GL_TOKEN=<REDACTED> npm run release:dry

> beta-channel-example@1.0.0 release:dry /src
> semantic-release --debug --dry-run

[10:38:19 PM] [semantic-release] › ℹ  Running semantic-release version 16.0.0-beta.18
  semantic-release:config load config from: /src/.releaserc.yaml +0ms
  semantic-release:config options values: { branches:
  semantic-release:config    [ 'master',
  semantic-release:config      { name: 'next', prerelease: 'rc' },
  semantic-release:config      { name: 'beta', prerelease: 'beta' } ],
  semantic-release:config   repositoryUrl:
  semantic-release:config    '<REDACTED>',
  semantic-release:config   tagFormat: 'v${version}',
  semantic-release:config   plugins:
  semantic-release:config    [ '@semantic-release/commit-analyzer',
  semantic-release:config      '@semantic-release/release-notes-generator',
  semantic-release:config      '@semantic-release/gitlab' ],
  semantic-release:config   success: false,
  semantic-release:config   fail: false,
  semantic-release:config   _: [],
  semantic-release:config   debug: true,
  semantic-release:config   'dry-run': true,
  semantic-release:config   d: true,
  semantic-release:config   dryRun: true,
  semantic-release:config   '$0': 'node_modules/.bin/semantic-release' } +15ms
  semantic-release:plugins options for @semantic-release/gitlab/verifyConditions: {} +0ms
[10:38:20 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/gitlab"
  semantic-release:plugins options for @semantic-release/commit-analyzer/analyzeCommits: {} +7ms
[10:38:20 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
  semantic-release:plugins options for @semantic-release/release-notes-generator/generateNotes: {} +2ms
[10:38:20 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
  semantic-release:plugins options for @semantic-release/gitlab/publish: {} +1ms
[10:38:20 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/gitlab"
[10:38:22 PM] [semantic-release] › ✖  An error occurred while running semantic-release: { Error: Command failed: git ls-remote --heads origin
remote: HTTP Basic: Access denied
fatal: Authentication failed for '<REDACTED>'


    at makeError (/src/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/src/node_modules/execa/index.js:278:16)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
  code: 128,
  stdout: '',
  stderr:
   "remote: HTTP Basic: Access denied\nfatal: Authentication failed for '<REDACTED>'\n",
  failed: true,
  signal: null,
  cmd: 'git ls-remote --heads origin',
  timedOut: false,
  killed: false }
{ Error: Command failed: git ls-remote --heads origin
remote: HTTP Basic: Access denied
fatal: Authentication failed for '<REDACTED>'


    at makeError (/src/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/src/node_modules/execa/index.js:278:16)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
  code: 128,
  stdout: '',
  stderr:
   "remote: HTTP Basic: Access denied\nfatal: Authentication failed for '<REDACTED>'\n",
  failed: true,
  signal: null,
  cmd: 'git ls-remote --heads origin',
  timedOut: false,
  killed: false }npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! beta-channel-example@1.0.0 release:dry: `semantic-release --debug --dry-run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the beta-channel-example@1.0.0 release:dry script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-05-01T22_38_22_432Z-debug.log
@jmodjeski75
Copy link
Contributor

I am encountering the same issue but with a GitHub repo instead. Do you have a gist of the purposed change?

@gr2m
Copy link
Member

gr2m commented May 16, 2019

If you could start a PR that’d be great, we can continue the discussion there :)

@jmodjeski75
Copy link
Contributor

Currently working on resolving all the places where origin is used instead of the correct auth url.

@alexan
Copy link

alexan commented Jun 4, 2019

did anybody figure out a workaround for this problem?

@jmodjeski75
Copy link
Contributor

@alexan a PR is open #1186 you are welcome to leverage my fork but it is as is until it is merged here.

@gr2m
Copy link
Member

gr2m commented Jun 4, 2019

Alexander, please let us know if @jmodjeski75’s fork fixed the issue for you

@alexan
Copy link

alexan commented Jun 5, 2019

@gr2m I tested the fork with devDependencies"semantic-release": "https://github.com/jmodjeski75/semantic-release" and did not get any error from git ls-remote --heads origin and successfully released a test package which previously failed

@pvdlg
Copy link
Member

pvdlg commented Jun 7, 2019

Fixed by #1186 in beta

@pvdlg pvdlg closed this as completed Jun 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants