Skip to content
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

Create skipInitiBuildIndex-multibranch.groovy #240

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

carlosrodlop
Copy link
Contributor

@carlosrodlop carlosrodlop commented Nov 11, 2024

This script ensure all Multibranch pipelines has enabled Initial Index Build Prevention to prevent https://www.cloudbees.com/blog/weathering-build-storms-in-the-enterprise in a clean workspaces.

It is useful for job migration use cases.

Copy link
Member

@duemir duemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see calls to save(). Do these changes actually persist?
Also, what if Multibranch Pipeline is child of Organization Folder and shouldn't be editable?

def emptyCount = 0
def nonEmptyCount = 0

Jenkins.instance.getAllItems(WorkflowMultiBranchProject).each { multibranchProject ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Jenkins.instance.getAllItems(WorkflowMultiBranchProject).each { multibranchProject ->
Jenkins.instance.allItems(WorkflowMultiBranchProject).each { multibranchProject ->

If I remember correctly, this should perform better.

println "===================================================================================="
}

enableBuildStrategy(dryRun)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enableBuildStrategy(dryRun)
try (ACLContext ctx = ACL.as2(ACL.SYSTEM2)) {
enableBuildStrategy(dryRun)
}

When script running through Script Conse this should avoid lookups to RBAC and the security realm, afaik.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this but I am getting this error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 74: expecting '{', found '(' @ line 74, column 5.
   try (ACLContext ctx = ACL.as2(ACL.SYSTEM2)) {
       ^
1 error

Looking into rbac plugin snippets examples seems correct but maybe is not valid in the groovy context.

Any ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is most likely not a valid groovy syntax, since I copy pasted this from Java.

@carlosrodlop
Copy link
Contributor Author

carlosrodlop commented Nov 12, 2024

Also, what if Multibranch Pipeline is child of Organization Folder and shouldn't be editable?

According to my test it also gets updated exiting child Multibranch projects too. Additionally, the new bytes I am pushing update the Organisation folder

image
image

@carlosrodlop
Copy link
Contributor Author

carlosrodlop commented Nov 13, 2024

@duemir I believe I have addressed all your comments. Shall we merge this thing?
It is still in BLOCKED state for its review

@duemir
Copy link
Member

duemir commented Nov 14, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants