Skip to content

Commit 006a7e7

Browse files
dylfJounQin
andauthored
fix: remove job token support (#184)
Co-authored-by: JounQin <admin@1stg.me>
1 parent bd3280a commit 006a7e7

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

.changeset/gold-maps-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"changesets-gitlab": patch
3+
---
4+
5+
fix: remove job token

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ GLOBAL_AGENT_NO_PROXY # Like above but for no proxied requests
4848

4949
GITLAB_HOST # optional, if you're using custom GitLab host, will fallback to `CI_SERVER_URL` if not provided
5050

51-
GITLAB_TOKEN # required, token with accessibility to push
52-
GITLAB_TOKEN_TYPE # optional, type of the provided token in GITLAB_TOKEN. defaults to personal access token. can be `job` if you provide the Gitlab CI_JOB_TOKEN or `oauth` if you use Gitlab Oauth token
51+
GITLAB_TOKEN # required, token with accessibility to push, package registries, and merge request APIs. Note the CI_JOB_TOKEN does not have sufficient permissons
52+
GITLAB_TOKEN_TYPE # optional, type of the provided token in GITLAB_TOKEN. defaults to personal access token. Can be `oauth` if you use Gitlab Oauth (personal access) token..
5353
GITLAB_CI_USER_NAME # optional, username with accessibility to push, used in pairs of the above token (if it was personal access token). If not set read it from the Gitlab API
5454
GITLAB_CI_USER_EMAIL # optional, default `gitlab[bot]@users.noreply.gitlab.com`
5555
GITLAB_COMMENT_TYPE # optional, type of the comment. defaults to `discussion`. can be set to `note` to not create a discussion instead of a thread

src/index.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,15 @@ export const createApi = (gitlabToken?: string) => {
2828
const token = gitlabToken || env.GITLAB_TOKEN
2929
const host = env.GITLAB_HOST
3030

31-
// we cannot use { [tokenType]: token } now
32-
// because it will break the type of the Gitlab constructor
33-
switch (env.GITLAB_TOKEN_TYPE) {
34-
case 'job': {
35-
return new Gitlab({
36-
host,
37-
jobToken: token,
38-
})
39-
}
40-
case 'oauth': {
41-
return new Gitlab({
42-
host,
43-
oauthToken: token,
44-
})
45-
}
46-
default: {
47-
return new Gitlab({
48-
host,
49-
token,
50-
})
51-
}
31+
if (env.GITLAB_TOKEN_TYPE === 'oauth') {
32+
return new Gitlab({
33+
host,
34+
oauthToken: token,
35+
})
5236
}
37+
38+
return new Gitlab({
39+
host,
40+
token,
41+
})
5342
}

0 commit comments

Comments
 (0)