Skip to content

Commit

Permalink
feat: Add GITLAB_HOST CI/CD Variable for GitLab Self-Hosted Server (#334
Browse files Browse the repository at this point in the history
)

* feat: Add GITLAB_HOST CI/CD Variable for GitLab Self-Hosted Server Operators

Self-hosted Gitlab server operators can input their address into the CI/CD variable in GITLAB_HOST. If no value is specified, it automatically points to the default address, https://gitlab.com

* fix: changed parameter name

changed parameter name
  • Loading branch information
langpeu authored Jun 19, 2024
1 parent dc4ca5c commit 083325a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/code-review-gpt/src/common/ci/gitlab/commentOnPR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export const commentOnPR = async (
signOff: string
): Promise<void> => {
try {
const { gitlabToken, projectId, mergeRequestIIdString } =
const { gitlabToken, projectId, mergeRequestIIdString, gitlabHost } =
getGitLabEnvVariables();
const mergeRequestIId = parseInt(mergeRequestIIdString, 10);
const api = new Gitlab({
token: gitlabToken,
host: gitlabHost,
});

const notes = await api.MergeRequestNotes.all(projectId, mergeRequestIId);
Expand Down
2 changes: 2 additions & 0 deletions packages/code-review-gpt/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const getGitLabEnvVariables = (): Record<string, string> => {
"CI_MERGE_REQUEST_IID",
"CI_COMMIT_SHA",
"GITLAB_TOKEN",
"GITLAB_HOST",
].filter((varName) => !process.env[varName]);
if (missingVars.length > 0) {
logger.error(`Missing environment variables: ${missingVars.join(", ")}`);
Expand All @@ -62,6 +63,7 @@ export const getGitLabEnvVariables = (): Record<string, string> => {
gitlabToken: process.env.GITLAB_TOKEN ?? "",
projectId: process.env.CI_PROJECT_ID ?? "",
mergeRequestIIdString: process.env.CI_MERGE_REQUEST_IID ?? "",
gitlabHost: process.env.GITLAB_HOST ?? "https://gitlab.com",
};
};

Expand Down

0 comments on commit 083325a

Please sign in to comment.