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

Revisit groovy delegates and property/method lookup #289

Merged
merged 1 commit into from
Sep 27, 2020

Conversation

Willem1987
Copy link
Contributor

Trying to leverage the default groovy delegating system to find properties and methods.

Trying to fix #276

@nre-ableton
Copy link
Contributor

Please remove all indentation changes in this branch, as they make this PR harder to review. I agree that there is some inconsistency in the codebase, but we need a better approach to solving it. This is already on the radar, please see #237.

@Willem1987
Copy link
Contributor Author

Willem1987 commented Sep 17, 2020

I think i removed the whitespace changes. This change works for properties, but seems not to be effective for methods yet.

@Willem1987
Copy link
Contributor Author

Should also fix #280 with latest commit

@Willem1987
Copy link
Contributor Author

Sorry for all the commits. I was having issues with shelved changes and different changelists with reverting and such. Tests all ran successfully locally.

I saw whitespace changes still in ParametersDeclaration which i can remove if needed.

@Willem1987 Willem1987 mentioned this pull request Sep 17, 2020
@nre-ableton
Copy link
Contributor

Ok, it's looking a bit better, but the branch history still needs some work. 987af5c should be squashed to a658ae4, and c74addd appears to have a default commit message created by your IDE (or some other tool).

@Willem1987
Copy link
Contributor Author

How would i go about this? c74addd Should have been part of Remove owner param in Create component. I'm trying with intelliJ as well as TortoiseGit but i don't usually update branch history

@Willem1987
Copy link
Contributor Author

It is now 1 commit

@nre-ableton
Copy link
Contributor

@Willem1987 Great, thanks. I'll try to take a look at this PR (and the others) today or tomorrow.

Copy link
Contributor

@nre-ableton nre-ableton left a comment

Choose a reason for hiding this comment

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

For now, I just have a few superficial suggestions. I'd like to check out this branch and play around with it a bit in order to really examine the new implementation.

@@ -16,15 +16,11 @@ class DeclarativePipeline extends GenericPipelineDeclaration {
properties.put('scm', 'scm')
}

def getParams() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is removed, what will happen to pipelines which call params.XYZ? Will that break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

params is a property/variable available on binding.

Params_Jenkinsfile still works.

Depending on if params is available and XYZ in new situation i can imagine it throwing a PropertyMissingException, but im not sure returing null would help the pipeline there

@Willem1987
Copy link
Contributor Author

Willem1987 commented Sep 17, 2020

As far as i can see the repo is public so you should be able to checkout. All the tests that were there still work and i updated Agent_bindings_Jenkinsfile to include a method in the script which now works.

Only thing that does not work is accessing the AGENT var from within the agentName() method, but this might be a groovy scoping thing. <- It is.

https://code-maven.com/groovy-variable-scope -> Declare local variable with def

Def creates a local variable not accessible within the agentName function. It works if i remove the def to make AGENT variable global. Opening the jenkinsFile with groovy editor also shows the compile time problem with the local var reference.

So i don't see any issues left so far with missing methods or params.

Copy link
Contributor

@nre-ableton nre-ableton left a comment

Choose a reason for hiding this comment

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

So this PR initially looks ok to me, but admittedly it touches some things here I have no experience with (such as declarative pipelines). That said, the tests still pass, and we certainly have pipelines which use env.XYZ and params.XYZ syntax, so it's probably not harmful.

I would really appreciate if another admin could have a look before merging, though. Perhaps @stchar? 🙏

@stchar
Copy link
Contributor

stchar commented Sep 25, 2020

Hi @Willem1987, @nre-ableton,
This PR is huge. I hope I can review it today.

Copy link
Contributor

@stchar stchar left a comment

Choose a reason for hiding this comment

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

Looks good to me

@stchar stchar linked an issue Sep 27, 2020 that may be closed by this pull request
@stchar stchar merged commit c58d0a5 into jenkinsci:master Sep 27, 2020
@stchar
Copy link
Contributor

stchar commented Sep 27, 2020

Merged. Thank you for all your efforts!

@Willem1987
Copy link
Contributor Author

Is there any upcoming release? I think with the pull requests merged i should be able to use the new version in our project.

@stchar
Copy link
Contributor

stchar commented Sep 27, 2020

I've just releases new version, usually it takes 1-2days to replicate artifacts to public maven repository

@stchar
Copy link
Contributor

stchar commented Sep 27, 2020

you can always checkout the tag (v1.8) and run ./gradlew publishToMavenLocal

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.

Calling method in agentdeclararion throws error Env. and Params. values not accessible without proper prefix
3 participants