Skip to content

Conversation

@DJViking
Copy link

No description provided.

@jenkinsadmin
Copy link
Member

Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests

@Brantone
Copy link
Contributor

Thanks!
I know there aren't a lot (or any) unit tests, but no time to start like the present :)
Can you throw a couple in?

@DJViking
Copy link
Author

I will see if I can add some unit tests

@DJViking
Copy link
Author

Is it possible for me to change the commit for this Pull Request, without having to make a new Pull Request? I need to change my email address in the commit.

Edit: I was able to change both author and committer email address. Looks like the Pull Request is still valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

At risk of nit-picky ... use tabs for consistency with files. Cheers.

@DJViking
Copy link
Author

I have tried this fix on a running Jenkins instance and it fails. I have a template project containing a groovy script in Postbuild within a flexible publish. The matrix parent is running this postbuild before starting all the configurations, and fails with a NullPointerException. I have made ProxyPublisher implement MatrixAggregatable, but not ProxyBuilder.

java.lang.NullPointerException
    at hudson.plugins.templateproject.ProxyMatrixAggregator.startBuild(ProxyMatrixAggregator.java:27)
    at org.jenkins_ci.plugins.flexible_publish.strategy.FailAtEndExecutionStrategy.matrixAggregationStartBuild(FailAtEndExecutionStrategy.java:95)
    at org.jenkins_ci.plugins.flexible_publish.ConditionalMatrixAggregator.startBuild(ConditionalMatrixAggregator.java:76)
    at org.jenkins_ci.plugins.flexible_publish.FlexibleMatrixAggregator.startBuild(FlexibleMatrixAggregator.java:62)
    at hudson.plugins.templateproject.ProxyMatrixAggregator.startBuild(ProxyMatrixAggregator.java:27)
    at hudson.plugins.templateproject.ProxyMatrixAggregator.startBuild(ProxyMatrixAggregator.java:27)
    at hudson.matrix.DefaultMatrixExecutionStrategyImpl.notifyStartBuild(DefaultMatrixExecutionStrategyImpl.java:212)
    at hudson.matrix.DefaultMatrixExecutionStrategyImpl.run(DefaultMatrixExecutionStrategyImpl.java:127)
    at hudson.matrix.MatrixBuild$MatrixBuildExecution.doRun(MatrixBuild.java:352)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.matrix.MatrixBuild.run(MatrixBuild.java:301)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
ERROR: Failed to evaluate groovy script.
java.lang.NullPointerException
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.tag(CliGitAPIImpl.java:1206)
    at hudson.plugins.git.GitAPI.tag(GitAPI.java:274)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
ERROR: [flexible-publish] aggregation with hudson.plugins.templateproject.ProxyMatrixAggregator@388d65af is aborted due to exception
java.lang.NullPointerException
    at hudson.plugins.templateproject.ProxyMatrixAggregator.endBuild(ProxyMatrixAggregator.java:53)
    at org.jenkins_ci.plugins.flexible_publish.strategy.FailAtEndExecutionStrategy.matrixAggregationEndBuild(FailAtEndExecutionStrategy.java:132)
    at org.jenkins_ci.plugins.flexible_publish.ConditionalMatrixAggregator.endBuild(ConditionalMatrixAggregator.java:87)
    at org.jenkins_ci.plugins.flexible_publish.FlexibleMatrixAggregator.endBuild(FlexibleMatrixAggregator.java:103)
    at hudson.plugins.templateproject.ProxyMatrixAggregator.endBuild(ProxyMatrixAggregator.java:53)
    at hudson.plugins.templateproject.ProxyMatrixAggregator.endBuild(ProxyMatrixAggregator.java:53)
    at hudson.matrix.MatrixBuild$MatrixBuildExecution.post2(MatrixBuild.java:402)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
    at hudson.model.Run.execute(Run.java:1766)
    at hudson.matrix.MatrixBuild.run(MatrixBuild.java:301)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)

Copy link
Member

Choose a reason for hiding this comment

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

It sounds that you need a null check here.

@DJViking
Copy link
Author

You are suggesting a nullcheck on publisherAggregator before I add it to the list?

@ikedam
Copy link
Member

ikedam commented Nov 10, 2015

Sure.
Groovy-postbuild perfomes aggregation only when "Run also for matrix parent" is checked, and returns null for the aggregator otherwise.

@DJViking
Copy link
Author

But should not matrix parent run the postbuild actions after running each configurations? It looks like here it attempted to run them before the configurations.

If i add a Groovy postbuild directly to a multi-configuration project and set "Run also for matrix parent", then that script is executed on matrix parent after each configurations have finished.

@ikedam
Copy link
Member

ikedam commented Nov 10, 2015

Aggegations consist of three phases:

  • startBuild: performed when a parent build starteds.
  • endRun: performed whenever a child build finishes.
  • endBuild: performed when a parent build finishes.

Refer to the javadoc for details.
http://javadoc.jenkins-ci.org/hudson/matrix/MatrixAggregator.html

@DJViking
Copy link
Author

Shouldn't in that case the MatrixAggregator for ProxyPublish only implement endBuild(), since that is when the publishers should run on matrix parent.

@DJViking
Copy link
Author

I have made some changes to the implementation. Taken some inspiration from ScriptPlugin https://github.com/JoelJ/ScriptPlugin

@ikedam
Copy link
Member

ikedam commented Nov 11, 2015

-1

There's no reason to prevent startBuild.
I think you completely misunderstand aggregations.

And you should not use git commit --ammend and git push --force. It makes hard to see what's the new change.

@DJViking
Copy link
Author

Perhaps I do misunderstand aggregations. The purpose for this fix was in my understanding to allow for executing publishers from template project on matrix parent after each configurations.
Anyhow I have removed the flags for runBefore and runAfter.

I added MatrixAggregatable aslo for ProxyBuilder. Will avoid amend and force from now on.

@DJViking
Copy link
Author

My first submitted fix for a Jenkins project did not go so well. Another problem has arisen.
If any of the build configurations finish (fail or success):

FATAL: cannot change build result while in COMPLETED
java.lang.IllegalStateException: cannot change build result while in COMPLETED
    at hudson.model.Run.setResult(Run.java:459)
    at org.jenkins_ci.plugins.run_condition.BuildStepRunner.setResult(BuildStepRunner.java:64)
    at org.jenkins_ci.plugins.run_condition.BuildStepRunner.access$200(BuildStepRunner.java:46)
    at org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail.conditionalRun(BuildStepRunner.java:151)
    at org.jenkins_ci.plugins.run_condition.BuildStepRunner.perform(BuildStepRunner.java:105)
    at org.jenkins_ci.plugins.flexible_publish.strategy.FailFastExecutionStrategy.matrixAggregationEndRun(FailFastExecutionStrategy.java:85)
    at org.jenkins_ci.plugins.flexible_publish.ConditionalMatrixAggregator.endRun(ConditionalMatrixAggregator.java:82)
    at org.jenkins_ci.plugins.flexible_publish.FlexibleMatrixAggregator.endRun(FlexibleMatrixAggregator.java:83)
    at hudson.plugins.templateproject.ProxyMatrixAggregator.endRun(ProxyMatrixAggregator.java:50)
    at hudson.matrix.DefaultMatrixExecutionStrategyImpl.notifyEndBuild(DefaultMatrixExecutionStrategyImpl.java:220)
    at hudson.matrix.DefaultMatrixExecutionStrategyImpl.run(DefaultMatrixExecutionStrategyImpl.java:163)
    at hudson.matrix.MatrixBuild$MatrixBuildExecution.doRun(MatrixBuild.java:352)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.matrix.MatrixBuild.run(MatrixBuild.java:301)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)

@Brantone
Copy link
Contributor

Any luck?

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.

4 participants