question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Environment variable "GITLAB_TOKEN" is required for GitLab releases

See original GitHub issue

As the title already says, I’m always getting

Environment variable “GITLAB_TOKEN” is required for GitLab releases

when executing npm run release My package.json looks like this (reduced verison):

{
  "name": "...",
  "version": "...",
  "description": "...",
  "main": "app.js",
  "scripts": {
    "release": "release-it"
  },
  "repository": {
    "type": "git",
    "url": "git+https://gitlab.com/.../... .git"
  },
  "author": "...",
  "license": "...",
  "bugs": {
    "url": "https://gitlab.com/.../.../issues"
  },
  "homepage": "https://gitlab.com/.../...#readme",
  "devDependencies": {
    "release-it": "^13.5.1"
  },
  "release-it": {
    "git": {
      "tagName": "v${version}",
      "requireCleanWorkingDir": false,
      "requireUpstream": false,
      "commitMessage": "Release v%s"
    },
    "gitlab": {
      "release": true
    },
    "npm": {
      "publish": false
    }
  },
  "dependencies": {
    "chart.js": "^2.9.3",
    "electron": "^8.2.0",
    "lowdb": "^1.0.0"
  }
}

I’m running on Win 10 Pro, and I tried to set GITLAB_TOKEN by entering get GITLAB_TOKEN = tokenHere

Edit:

get | findstr "GITLAB_TOKEN" also returns my token which confuses me even more because it’s definetly set.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
webprocommented, Apr 7, 2020

Added a section about environment variables, including a good cross-os solution: https://github.com/release-it/release-it/blob/master/docs/environment-variables.md

2reactions
rchlcommented, Apr 6, 2020

After I typed $ export GITHUB_TOKEN="<my token>" in my terminal (note the export), it worked.

Yes, you really need to export the variable (docs).

Or just prefix your npm command with a token like:

GITLAB_TOKEN=asdf npm run release

That way it will only be set for the duration of the command which should be better from security standpoint.

(But this won’t work on Windows. I know there is some npm package that handles that cross-platform but I forgot the name of it)

EDIT: here it is https://www.npmjs.com/package/cross-env

Read more comments on GitHub >

github_iconTop Results From Across the Web

GitLab CI/CD variables
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.
Read more >
Semantic release not accepting GITLAB_TOKEN on gitlab ...
So in the end the problem was that I had to add the created GITLAB_TOKEN access token in Settings > CI/CD > Variables....
Read more >
Readme · Variables · Ci · Help · GitLab
When receiving a job from GitLab CI, the Runner prepares the build environment. It starts by setting a list of predefined variables (environment...
Read more >
GitLab - Jenkins Plugins
The first is the Git configuration, where Jenkins clones your git repo. The GitLab Plugin will set some environment variables when GitLab ......
Read more >
Configure Your GitLab CI Environment Variable
Setting an environment variable in GitLab CI occurs on a per-repository basis. This example demonstrates how to create a variable for your API...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found