Skip to content

Commit a7d0161

Browse files
authored
Add conversion from Jenkins variables to related Git provider variables (#6658)
1 parent 663b45a commit a7d0161

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

.cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@
11481148
"mypy",
11491149
"myrepository",
11501150
"myrulesfolder",
1151+
"mytoken",
11511152
"natbib",
11521153
"nbbytes",
11531154
"ndiff",

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
3737

3838
- CI
3939
- Optimize performances of standalone linters releases
40+
- Add conversion from Jenkins variables to related Git provider variables
4041

4142
- mega-linter-runner
4243
- Handle upgrade of stefanzweifel/git-auto-commit-action to v7

mega-linter-runner/generators/mega-linter/templates/Jenkinsfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,56 @@ pipeline {
99
// https://megalinter.io/latest/config-file/
1010
DEFAULT_WORKSPACE = "${WORKSPACE}"
1111

12+
// Uncomment below if used with Bitbucket
13+
/*
14+
TOKEN = credentials('mytoken')
15+
BITBUCKET_REPO_ACCESS_TOKEN = "${env.TOKEN_PSW}"
16+
BITBUCKET_REPO_FULL_NAME = "${env.BITBUCKET_OWNER}/${env.BITBUCKET_REPOSITORY}"
17+
BITBUCKET_GIT_HTTP_ORIGIN = "${env.GIT_URL.replaceAll('\\.git$', '')}"
18+
BITBUCKET_BUILD_NUMBER = "${env.BUILD_NUMBER}"
19+
BITBUCKET_PR_ID = "${env.CHANGE_ID}"
20+
BITBUCKET_STEP_UUID = "${env.BUILD_ID}"
21+
*/
22+
23+
// Uncomment below if used with GitLab
24+
/*
25+
GITLAB_TOKEN = credentials('gitlab-token')
26+
CI_JOB_TOKEN = "${env.GITLAB_TOKEN_PSW}"
27+
CI_SERVER_URL = "${env.gitlabHost ?: 'https://gitlab.com'}"
28+
CI_PROJECT_NAME = "${env.gitlabSourceRepoName ?: env.JOB_NAME}"
29+
CI_PROJECT_ID = "${env.gitlabSourceRepoId ?: env.JOB_NAME}"
30+
CI_JOB_URL = "${env.BUILD_URL}"
31+
CI_MERGE_REQUEST_ID = "${env.gitlabMergeRequestIid ?: env.CHANGE_ID ?: ''}"
32+
CI_OPEN_MERGE_REQUESTS = "${env.gitlabMergeRequestLastCommit ?: ''}"
33+
CI_COMMIT_SHA = "${env.gitlabMergeRequestLastCommit ?: env.GIT_COMMIT}"
34+
*/
35+
36+
// Uncomment below if used with GitHub
37+
/*
38+
GITHUB_TOKEN = credentials('github-token')
39+
PAT = "${env.GITHUB_TOKEN_PSW}"
40+
GITHUB_REPOSITORY = "${env.CHANGE_URL ? env.CHANGE_URL.replaceAll('https://github.com/', '').split('/pull/')[0] : env.GIT_URL?.replaceAll('^.*github.com[:/]', '')?.replaceAll('\\.git$', '')}"
41+
GITHUB_SERVER_URL = "https://github.com"
42+
GITHUB_API_URL = "https://api.github.com"
43+
GITHUB_REF = "${env.CHANGE_BRANCH ?: env.BRANCH_NAME ?: env.GIT_BRANCH}"
44+
GITHUB_SHA = "${env.GIT_COMMIT}"
45+
GITHUB_RUN_ID = "${env.BUILD_ID}"
46+
GITHUB_WORKFLOW = "${env.JOB_NAME}"
47+
GITHUB_JOB = "${env.STAGE_NAME ?: 'MegaLinter'}"
48+
*/
49+
50+
// Uncomment below if used with Azure DevOps
51+
/*
52+
AZURE_TOKEN = credentials('azure-system-token')
53+
SYSTEM_ACCESSTOKEN = "${env.AZURE_TOKEN_PSW}"
54+
SYSTEM_COLLECTIONURI = "${env.ADO_COLLECTION_URI ?: 'https://dev.azure.com/your-org/'}"
55+
SYSTEM_TEAMPROJECT = "${env.ADO_TEAM_PROJECT ?: env.JOB_NAME}"
56+
BUILD_BUILDID = "${env.BUILD_ID}"
57+
BUILD_REPOSITORY_ID = "${env.ADO_REPOSITORY_ID ?: env.GIT_URL?.tokenize('/')?.last()?.replace('.git','')}"
58+
SYSTEM_PULLREQUEST_PULLREQUESTID = "${env.CHANGE_ID ?: ''}"
59+
SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI = "${env.GIT_URL}"
60+
*/
61+
1262
// Disable LLM Advisor for bot PRs (dependabot, renovate, etc.)
1363
// Note: Jenkins has limited access to PR metadata, this is a basic check
1464
LLM_ADVISOR_ENABLED = script {

0 commit comments

Comments
 (0)