-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from test-results-reporter/fix/gitlab-branch-…
…hyperlink-issue fix: Incorrect branch and PR hyperlink for gitlab ci extension
- Loading branch information
Showing
11 changed files
with
406 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const ENV = process.env; | ||
|
||
/** | ||
* @returns {import('../../extensions/extensions').ICIInfo} | ||
*/ | ||
function info() { | ||
const azure_devops = { | ||
ci: 'AZURE_DEVOPS_PIPELINES', | ||
git: 'AZURE_DEVOPS_REPOS', | ||
repository_url: ENV.BUILD_REPOSITORY_URI, | ||
repository_name: ENV.BUILD_REPOSITORY_NAME, | ||
repository_ref: ENV.BUILD_SOURCEBRANCH, | ||
repository_commit_sha: ENV.BUILD_SOURCEVERSION, | ||
branch_url: '', | ||
branch_name: '', | ||
pull_request_url:'', | ||
pull_request_name: '', | ||
build_url: ENV.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI + ENV.SYSTEM_TEAMPROJECT + '/_build/results?buildId=' + ENV.BUILD_BUILDID, | ||
build_number: ENV.BUILD_BUILDNUMBER, | ||
build_name: ENV.BUILD_DEFINITIONNAME, | ||
build_reason: ENV.BUILD_REASON, | ||
user: ENV.BUILD_REQUESTEDFOR | ||
} | ||
|
||
azure_devops.branch_url = azure_devops.repository_url + azure_devops.repository_ref.replace('refs/heads/', '/tree/'); | ||
azure_devops.branch_name = azure_devops.repository_ref.replace('refs/heads/', ''); | ||
|
||
if (azure_devops.repository_ref.includes('refs/pull')) { | ||
azure_devops.pull_request_url = azure_devops.repository_url + azure_devops.repository_ref.replace('refs/pull/', '/pull/'); | ||
azure_devops.pull_request_name = azure_devops.repository_ref.replace('refs/pull/', '').replace('/merge', ''); | ||
} | ||
return azure_devops; | ||
} | ||
|
||
module.exports = { | ||
info | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const ENV = process.env; | ||
|
||
/** | ||
* @returns {import('../../extensions/extensions').ICIInfo} | ||
*/ | ||
function info() { | ||
const github = { | ||
ci: 'GITHUB_ACTIONS', | ||
git: 'GITHUB', | ||
repository_url: ENV.GITHUB_SERVER_URL + '/' + ENV.GITHUB_REPOSITORY, | ||
repository_name: ENV.GITHUB_REPOSITORY, | ||
repository_ref: ENV.GITHUB_REF, | ||
repository_commit_sha: ENV.GITHUB_SHA, | ||
branch_url: '', | ||
branch_name: '', | ||
pull_request_url:'', | ||
pull_request_name: '', | ||
build_url: ENV.GITHUB_SERVER_URL + '/' + ENV.GITHUB_REPOSITORY + '/actions/runs/' + ENV.GITHUB_RUN_ID, | ||
build_number: ENV.GITHUB_RUN_NUMBER, | ||
build_name: ENV.GITHUB_WORKFLOW, | ||
build_reason: ENV.GITHUB_EVENT_NAME, | ||
user: ENV.GITHUB_ACTOR, | ||
} | ||
|
||
github.branch_url = github.repository_url + github.repository_ref.replace('refs/heads/', '/tree/'); | ||
github.branch_name = github.repository_ref.replace('refs/heads/', ''); | ||
|
||
if (github.repository_ref.includes('refs/pull')) { | ||
github.pull_request_url = github.repository_url + github.repository_ref.replace('refs/pull/', '/pull/'); | ||
github.pull_request_name = github.repository_ref.replace('refs/pull/', '').replace('/merge', ''); | ||
} | ||
|
||
return github | ||
} | ||
|
||
module.exports = { | ||
info | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const ENV = process.env; | ||
|
||
/** | ||
* @returns {import('../../extensions/extensions').ICIInfo} | ||
*/ | ||
function info() { | ||
const gitlab = { | ||
ci: 'GITLAB', | ||
git: 'GITLAB', | ||
repository_url: ENV.CI_PROJECT_URL, | ||
repository_name: ENV.CI_PROJECT_NAME, | ||
repository_ref: '/-/tree/' + (ENV.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME || ENV.CI_COMMIT_REF_NAME), | ||
repository_commit_sha: ENV.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA || ENV.CI_COMMIT_SHA, | ||
branch_url: ENV.CI_PROJECT_URL + '/-/tree/' + (ENV.CI_COMMIT_REF_NAME || ENV.CI_COMMIT_BRANCH), | ||
branch_name: ENV.CI_COMMIT_REF_NAME || ENV.CI_COMMIT_BRANCH, | ||
pull_request_url:'', | ||
pull_request_name: '', | ||
build_url: ENV.CI_JOB_URL, | ||
build_number: ENV.CI_JOB_ID, | ||
build_name: ENV.CI_JOB_NAME, | ||
build_reason: ENV.CI_PIPELINE_SOURCE, | ||
user: ENV.GITLAB_USER_LOGIN || ENV.CI_COMMIT_AUTHOR | ||
} | ||
|
||
if (ENV.CI_OPEN_MERGE_REQUESTS) { | ||
const pr_number = ENV.CI_OPEN_MERGE_REQUESTS.split("!")[1]; | ||
gitlab.pull_request_name = "#" + pr_number; | ||
gitlab.pull_request_url = ENV.CI_PROJECT_URL + "/-/merge_requests/" + pr_number; | ||
} | ||
|
||
return gitlab | ||
} | ||
|
||
module.exports = { | ||
info | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const os = require('os'); | ||
const github = require('./github'); | ||
const gitlab = require('./gitlab'); | ||
const jenkins = require('./jenkins'); | ||
const azure_devops = require('./azure-devops'); | ||
const system = require('./system'); | ||
|
||
const ENV = process.env; | ||
|
||
/** | ||
* @returns {import('../../extensions/extensions').ICIInfo} | ||
*/ | ||
function getCIInformation() { | ||
const ci_info = getBaseCIInfo(); | ||
const system_info = system.info(); | ||
return { | ||
...ci_info, | ||
...system_info | ||
} | ||
} | ||
|
||
function getBaseCIInfo() { | ||
if (ENV.GITHUB_ACTIONS) { | ||
return github.info(); | ||
} | ||
if (ENV.GITLAB_CI) { | ||
return gitlab.info(); | ||
} | ||
if (ENV.JENKINS_URL) { | ||
return jenkins.info(); | ||
} | ||
if (ENV.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) { | ||
return azure_devops.info(); | ||
} | ||
return getDefaultInformation(); | ||
} | ||
|
||
function getDefaultInformation() { | ||
return { | ||
ci: ENV.TEST_BEATS_CI_NAME, | ||
git: ENV.TEST_BEATS_CI_GIT, | ||
repository_url: ENV.TEST_BEATS_CI_REPOSITORY_URL, | ||
repository_name: ENV.TEST_BEATS_CI_REPOSITORY_NAME, | ||
repository_ref: ENV.TEST_BEATS_CI_REPOSITORY_REF, | ||
repository_commit_sha: ENV.TEST_BEATS_CI_REPOSITORY_COMMIT_SHA, | ||
branch_url: ENV.TEST_BEATS_BRANCH_URL, | ||
branch_name: ENV.TEST_BEATS_BRANCH_NAME, | ||
pull_request_url: ENV.TEST_BEATS_PULL_REQUEST_URL, | ||
pull_request_name: ENV.TEST_BEATS_PULL_REQUEST_NAME, | ||
build_url: ENV.TEST_BEATS_CI_BUILD_URL, | ||
build_number: ENV.TEST_BEATS_CI_BUILD_NUMBER, | ||
build_name: ENV.TEST_BEATS_CI_BUILD_NAME, | ||
build_reason: ENV.TEST_BEATS_CI_BUILD_REASON, | ||
user: ENV.TEST_BEATS_CI_USER || os.userInfo().username | ||
} | ||
} | ||
|
||
module.exports = { | ||
getCIInformation | ||
} |
Oops, something went wrong.