Skip to content

Commit

Permalink
Use Job-Token over Private-Token header if CI_JOB_TOKEN is set
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Feb 3, 2021
1 parent b114295 commit f1b1144
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/plugin/gitlab/GitLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ class GitLab extends Release {

get client() {
if (this._client) return this._client;
const { tokenHeader } = this.getContext();
this._client = got.extend({
prefixUrl: this.baseUrl,
method: 'POST',
headers: {
'user-agent': 'webpro/release-it',
'Private-Token': this.token
[tokenHeader]: this.token
}
});
return this._client;
Expand All @@ -38,6 +39,10 @@ class GitLab extends Release {
this.origin = origin || `https://${repo.host}`;
this.baseUrl = `${this.origin}/api/v4`;
this.id = encodeURIComponent(repo.repository);
const tokenHeader = 'CI_JOB_TOKEN' in process.env ? 'Job-Token' : 'Private-Token';
this.setContext({
tokenHeader
});

if (skipChecks) return;

Expand Down

0 comments on commit f1b1144

Please sign in to comment.