-
Notifications
You must be signed in to change notification settings - Fork 23
Fix groovy code format with linters #1150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix groovy code format with linters #1150
Conversation
lentzi90
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup!
I added suggestions for cleaning up nested withCredentials also.
The quoting was a bit confusing for me first but it seems consistent. If the string contains variables, then " is used, otherwise '. Maybe it helps with accidental evaluation, I don't know but it is ok for me.
e5c1f96 to
ac29806
Compare
Thanks for review @lentzi90. I fixed all nested withCredentials issue as well. |
a149794 to
c90c65d
Compare
lentzi90
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
adilGhaffarDev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR applies Groovy linter formatting fixes to Jenkins pipeline files and adds a linter configuration. The changes include standardizing indentation, converting double quotes to single quotes for static strings, adding type declarations to variables, removing unused imports, and restructuring nested credential blocks.
- Adds
.groovylintrc.jsonconfiguration file for Groovy linting - Standardizes code formatting across all Jenkins pipeline files (indentation, quotes, spacing)
- Adds explicit type declarations to variables (
string,int) - Flattens nested
withCredentialsblocks for better readability
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| .groovylintrc.json | Adds linter configuration with recommended rules and specific exclusions |
| jenkins/jobs/pre_release_tests.groovy | Formats code, adds type declarations, changes quotes to single quotes |
| jenkins/jobs/image_building.groovy | Formats code, adds type declarations, changes quotes to single quotes |
| jenkins/jobs/e2e_features_test.groovy | Formats code, renames TIMEOUT to buildTimeout, adds type declarations |
| jenkins/jobs/dynamic_fullstack_building.groovy | Formats code, renames TIMEOUT to buildTimeout, flattens credentials |
| jenkins/jobs/dev_env_integration_tests.groovy | Formats code, renames TIMEOUT to buildTimeout, adds type declarations |
| jenkins/jobs/clean_resources.groovy | Formats code, renames TIMEOUT to buildTimeout, adds type declarations |
| jenkins/jobs/capm3-e2e-tests.groovy | Formats code, renames TIMEOUT to buildTimeout |
| jenkins/jobs/bmo_e2e_optional_tests.groovy | Formats code, renames TIMEOUT to buildTimeout, adds type declarations |
| jenkins/jobs/bml_integration_tests.groovy | Formats code, changes BOOTSTRAP_CLUSTER to EPHEMERAL_CLUSTER, has syntax error |
Comments suppressed due to low confidence (1)
jenkins/jobs/bmo_e2e_optional_tests.groovy:1
- Variables declared with
stringtype at script scope cannot be referenced later in the pipeline. In Groovy/Jenkins pipelines, script-level variables should be declared without explicit type annotations (usedefor no qualifier). Thestringtype is not valid for variable declarations in this context.
// 3 hour
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ci_git_url = "https://github.com/metal3-io/project-infra.git" | ||
| string UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git" | ||
| echo "Test triggered from ${UPDATED_REPO}" | ||
| string ci_git_url = 'https://github.com/metal3-io/project-infra.git' |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables declared with string type at script scope cannot be referenced in the pipeline environment block (line 39). In Groovy/Jenkins pipelines, script-level variables should be declared without explicit type annotations (use def or no qualifier). The string type is not valid for variable declarations in this context.
| string ci_git_url = 'https://github.com/metal3-io/project-infra.git' | |
| def ci_git_url = 'https://github.com/metal3-io/project-infra.git' |
| string UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git" | ||
| echo "Test triggered from ${UPDATED_REPO}" | ||
| string ci_git_url = 'https://github.com/metal3-io/project-infra.git' |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables declared with string type at script scope cannot be referenced in the pipeline environment block (line 31). In Groovy/Jenkins pipelines, script-level variables should be declared without explicit type annotations (use def or no qualifier). The string type is not valid for variable declarations in this context.
| string UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git" | |
| echo "Test triggered from ${UPDATED_REPO}" | |
| string ci_git_url = 'https://github.com/metal3-io/project-infra.git' | |
| def UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git" | |
| echo "Test triggered from ${UPDATED_REPO}" | |
| def ci_git_url = 'https://github.com/metal3-io/project-infra.git' |
jenkins/jobs/capm3-e2e-tests.groovy
Outdated
| script { | ||
| string UPDATED_REPO = "https://github.com/${env.REPO_OWNER}/${env.REPO_NAME}.git" | ||
| echo "Test triggered from ${UPDATED_REPO}" | ||
| string ci_git_url = 'https://github.com/metal3-io/project-infra.git' |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables declared with string type at script scope cannot be referenced later in the script. In Groovy/Jenkins pipelines, script-level variables should be declared without explicit type annotations (use def or no qualifier). The string type is not valid for variable declarations in this context.
| string ci_git_url = 'https://github.com/metal3-io/project-infra.git' | |
| def ci_git_url = 'https://github.com/metal3-io/project-infra.git' |
| archiveArtifacts "logs-${env.BUILD_TAG}.tgz" | ||
| } | ||
| } | ||
| archiveArtifacts "logs-${env.BUILD_TAG}.tgz" |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The archiveArtifacts call on line 105 is duplicated (also appears on line 102). This will cause the same artifacts to be archived twice. Remove the duplicate on line 105.
| archiveArtifacts "logs-${env.BUILD_TAG}.tgz" |
|
PTAL Copilot review @Sunnatillo |
c90c65d to
8b7c3ac
Compare
ec52fe6 to
b64271f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Sunnatillo <[email protected]>
b64271f to
2f314cf
Compare
|
Added #1153 to add prow linter job for groovy after we merge this. |
adilGhaffarDev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adilGhaffarDev, lentzi90 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/override metal3-ubuntu-e2e-integration-test-main |
|
@Sunnatillo: Overrode contexts on behalf of Sunnatillo: metal3-ubuntu-e2e-integration-test-main In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This PR fixes jenkins pipeline code formats files with Groovy linters