Skip to content

[JENKINS-51170] Enable the usage of the StepEnvironmentContributor extensionpoint #229

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

Merged
merged 1 commit into from
Feb 1, 2019

Conversation

t-8ch
Copy link
Contributor

@t-8ch t-8ch commented Jun 1, 2018

Support the new StepEnvironmentContributor hook introduced in
jenkinsci/workflow-step-api-plugin#36.

This depends on jenkinsci/workflow-step-api-plugin#36.
The dependency version number used depends on the incrementalifyiation (JEP 305).
If requested I can perform this and submit another PR.

@jglick jglick self-requested a review June 1, 2018 14:46
@jglick
Copy link
Member

jglick commented Jun 1, 2018

The dependency version number used depends on the incrementalifyiation (JEP 305).
If requested I can perform this

Yes should suffice to update the parent (currently to 3.12) and

mvn incrementals:incrementalify

Could be done in this PR so far as I am concerned.

@jglick
Copy link
Member

jglick commented Jun 1, 2018

(Somehow the CI build seems to be running even without the consume-incrementals profile, not sure why. Might be an artifact of mirror setup on the CI builder.)

@t-8ch
Copy link
Contributor Author

t-8ch commented Jun 1, 2018

I got an error with access restrictions (DoNotUse).
Will try again next week, just left for the weekend.

@t-8ch
Copy link
Contributor Author

t-8ch commented Jun 4, 2018

The incrementalization is blocked on jenkinsci/lib-access-modifier#12
(Or we work around by removing some access modifiers)

@jglick
Copy link
Member

jglick commented Jun 4, 2018

I got an error with access restrictions (DoNotUse).

Just switch to NoExternalUse.

PR seems to have a bunch of test failures.

@t-8ch t-8ch force-pushed the step-environment-contributor branch 3 times, most recently from 92cc5b0 to 6796532 Compare June 5, 2018 12:36
@t-8ch
Copy link
Contributor Author

t-8ch commented Jun 5, 2018

The hooks work so far for steps. The logic in jenkinsci/workflow-support-plugin#62 is actually sufficient. This PR only contains tests.

I am not sure about also calling the hooks for EnvActionImpl.
This would require to get the current interpreter state from groovy, getting the enclosing scope and somehow using this to fetch the parents scope StepContext from somewhere inside the CPS engine.

Any opinions if this part is required/wanted/superfluous/etc?

@jglick jglick mentioned this pull request Jun 6, 2018
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Minor comments, but looks OK given the upstreams.

@t-8ch t-8ch force-pushed the step-environment-contributor branch from 6796532 to 495d886 Compare June 7, 2018 10:09
@t-8ch
Copy link
Contributor Author

t-8ch commented Jun 7, 2018

@jglick I implemented your comments. Thanks for the review!
EDIT: this depends on #230 now.

@t-8ch t-8ch force-pushed the step-environment-contributor branch 2 times, most recently from 027d4a5 to a49d018 Compare June 14, 2018 08:03
@t-8ch t-8ch force-pushed the step-environment-contributor branch from a49d018 to 0a459b7 Compare January 15, 2019 16:14
Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

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

@t-8ch Here is the change you need to fix the enforcer issue:

diff --git a/pom.xml b/pom.xml
index 97bd8cc5..1b796251 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     <parent>
         <groupId>org.jenkins-ci.plugins</groupId>
         <artifactId>plugin</artifactId>
-        <version>3.28</version>
+        <version>3.32</version>
         <relativePath />
     </parent>
     <groupId>org.jenkins-ci.plugins.workflow</groupId>

Unfortunately, after fixing that, I get a lot of test failures that appear to be caused by the workflow-support patch (for example, try ArgumentsActionTestImpl#testArgumentDescriptions). It looks like the addition of get(TaskListener.class) is causing failures in some scenarios where the node is not active or has completed. Here is an example stack trace:

java.io.IOException: cannot start writing logs to a finished node org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode[id=3] echo in CpsFlowExecution[Owner[argumentDescription/1:argumentDescription #1]]
	at org.jenkinsci.plugins.workflow.support.DefaultStepContext.getListener(DefaultStepContext.java:107)
	at org.jenkinsci.plugins.workflow.support.DefaultStepContext.get(DefaultStepContext.java:78)
	at org.jenkinsci.plugins.workflow.support.DefaultStepContext.get(DefaultStepContext.java:72)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:239)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:176)

Maybe workflow-support should call the old API in the cases where TaskListener.class is not available, or pass TaskListener.NULL or something, but I'm not sure what the best approach would be.

@t-8ch
Copy link
Contributor Author

t-8ch commented Jan 17, 2019

I see the following alternatives to aquire a listener:

  1. getExecution().getOwner().getListener()
    • Is used just above
  2. Remove the check that is throwing the exception (only for our internal call)
    • May have side-effects
  3. Do the same as EnvActionImpl.getListener()
    • Looks to be similar to 1), but falls back to plain logging

Personally I think 3) seems to be the best.

@t-8ch
Copy link
Contributor Author

t-8ch commented Jan 17, 2019

I implemented prototypes for all three scenarios and all of them pass the testsuites of workflow-support and workflow-cps.

@dwnusbaum
Copy link
Member

Thanks for looking into all of the options! Given that the line immediately above the new line in workflow-support uses getExecution().getOwner().getListener(), option 1 seems the best to me for consistency with that behavior. Option 2 seems a little worrying because of potential side effects like you noted, and it seems like if we used option 3, anything sent to the system logs would probably just end up being unhelpful log spam since it wouldn't be associated with the particular build it came from. So my preference would be 1 over 3 over 2.

@t-8ch
Copy link
Contributor Author

t-8ch commented Jan 17, 2019

Will do. I won't get around until tomorrow though. If you want feel free to take a shot at it.

@jglick
Copy link
Member

jglick commented Jan 17, 2019

getExecution().getOwner().getListener()

Sounds good but better do it in DefaultStepContext.getListener: jenkinsci/workflow-support-plugin#62 (comment)

Do the same as EnvActionImpl.getListener()

No, do not do that.

Partially verified

This commit is signed with the committer’s verified signature.
estesp’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
…tensionpoint

Support the new StepEnvironmentContributor hook introduced in
jenkinsci/workflow-step-api-plugin#36.
@t-8ch t-8ch force-pushed the step-environment-contributor branch from 0a459b7 to 213af04 Compare January 18, 2019 09:53
@t-8ch
Copy link
Contributor Author

t-8ch commented Jan 18, 2019

I went with 2 with a fallback to 1, as recommended by @jglick . The tests seem to be happy.

@dwnusbaum dwnusbaum merged commit d9f2a6c into jenkinsci:master Feb 1, 2019
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.

None yet

3 participants