semantic-release: `EGITNOPERMISSION` Error When Running semantic-release on Travis CI

Current behavior

Hey semantic-release folks,

I’m trying to set up semantic-release on Travis CI for my repository, but I’m encountering an EGITNOPERMISSION error, which prevents semantic-release from pushing tags to GitHub. One thing to note this works on public repos, but not private repos for some reason.

The error message states:

Cannot push to the Git repository. semantic-release cannot push the version tag to the branch master.

I’ve already added a GitHub Personal Access Token (GH_TOKEN) with repo scope to my Travis CI environment variables, and I verified that it exists in the build logs. My .travis.yml includes a before_script that sets up Git authentication manually:

before_script:
  - git config --global user.name ""
  - git config --global user.email ""
  - git remote set-url origin https://$GH_TOKEN@github.com/repo/name
  - git remote -v
  - git config --list
  - echo "Token exists: $([[ ! -z $GH_TOKEN ]] && echo 'yes' || echo 'no')"

I also confirmed that my .releaserc.json file has the correct repository URL, I manually tested pushing to GitHub with the following command inside my Travis CI job:

git push https://$GH_TOKEN@github.com/repo/name

I’ve also use --dry-run via:

git push --dry-run https://{$GH_TOKEN}@github.com/repo/name HEAD:master

The results are:

Everything is up to date.

I also run:

git push --dry-run https://{$GH_TOKEN}@github.com/repo/name.git HEAD:master

Adding the .git to the repo name and I get:

Everything is up to date.

I’ve also tried deleting and regenerating the GitHub token, ensuring that it’s correctly added to Travis CI, but the issue persists.

Additionally, I’m seeing warnings about marked-mangle and marked-gfm-heading-id, even after installing them in the install section of my .travis.yml.

Any help would be greatly appreciated, I’m stuck here a little. First time in a while!

Expected behavior

Travis CI releases using semantic-release.

semantic-release version

21.0.2

CI environment

Travis CI

Plugins used

No response

semantic-release configuration

Private repo.

CI logs

SemanticReleaseError: Cannot push to the Git repository.
    at default (file:///home/travis/build/Montana/semantic-release/node_modules/semantic-release/lib/get-error.js:6:10)
    at run (file:///home/travis/build/Montana/semantic-release/node_modules/semantic-release/index.js:101:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.default (file:///home/travis/build/Montana/semantic-release/node_modules/semantic-release/index.js:275:22)
    at async default (file:///home/travis/build/Montana/semantic-release/node_modules/semantic-release/cli.js:55:5) {
  code: 'EGITNOPERMISSION',

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 23 (2 by maintainers)

Most upvoted comments

I have the same problem. In the travis.yml in the deploy step we run “npx semantic-release” it has worked well since we started using it probably 4 years ago. In the last 2 months it has suddenly stopped working with the same error the OP documented.

@Montana @qasim-at-tci Should x-access-token be replaced with something, or is this the right value for the username?

before_deploy:
  - git config --global credential.helper store
  - git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"

@vitor-gyant The format https://x-access-token:${GITHUB_TOKEN}@github.com/USERNAME/REPO.git explicitly provides a placeholder username (x-access-token), which ensures that the token is correctly interpreted as the password so this doesn’t need to be changed.

My .travis.yml includes a before_script that sets up Git authentication manually

you should not need to do this

@travi, I totally agree with you, but the only way we were able to get semantic-release to work is by adding the following lines:

before_script:
  - git config --global credential.helper store
  - git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"

As noted, this is for a private repository. The --dry-run option worked locally but did not work when running in CI.

Anyway, @qasim-at-tci and I have resolved the issue. I recommend adding documentation or a note, as we have found no other way to make semantic-release work in a private repository.

Worth noting as well, the same behavior occurs on GitHub Actions, have a wonderful weekend!