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

Add support for Pipeline jobs #28

Merged
merged 4 commits into from
Sep 22, 2016
Merged

Add support for Pipeline jobs #28

merged 4 commits into from
Sep 22, 2016

Conversation

md5
Copy link
Contributor

@md5 md5 commented Sep 21, 2016

This PR updates this plugin to work correctly with pipeline jobs.

The main change is to change references to AbstractProject, AbstractBuild, and BuildListener to refer to Job, Run, and TaskListener respectively. Another change is to implement SimpleBuildStep.LastBuildAction to allow build actions to contribute actions to a project.

One thing I did not do was to make this plugin actually depend on the Pipeline API, so in order to use the publishers, you'll need to use the step metastep. Here's an example for RcovPublisher:

step([
    $class: 'RcovPublisher',
    reportDir: "coverage/rcov",
    targets: [
        [metric: "CODE_COVERAGE", healthy: 75, unhealthy: 50, unstable: 30]
    ]
])

Many thanks to @SuperTux88 for starting this work in 61f5f2a and to @cprice404 for his helpful guide to refactoring Jenkins plugins to be pipeline-compatible: https://jenkins.io/blog/2016/05/25/update-plugin-for-pipeline/

SuperTux88 and others added 3 commits July 23, 2016 20:45
it somehow works now (doesn't crash anymore), but doesn't display
anything ... so this would need more work

also tests seems to be broken
This allows project actions to be attached to pipeline jobs based on the
presence of an associated build action
@@ -9,14 +9,14 @@
@SuppressWarnings("unchecked")
public abstract class AbstractRubyMetricsProjectAction<T extends AbstractRubyMetricsBuildAction> extends Actionable implements ProminentProjectAction {

protected final AbstractProject<?, ?> project;
protected final Job<?, ?> job;
Copy link
Contributor Author

@md5 md5 Sep 22, 2016

Choose a reason for hiding this comment

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

I think this rename may actually be a breaking change for deserializing old build records. It's been a while since I've had to deal with this in Jenkins (it was Hudson last time I had to do so), but if I recall this can be fixed by implementing readResolve().

Update: Looks like I have to implement readResolve() and put back the old field with the transient keyword: https://wiki.jenkins-ci.org/display/JENKINS/Hint+on+retaining+backward+compatibility

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 believe I have addressed this in c67d3aa

It would probably be nice to add a test that attempts to load an old build record. If any Jenkins maintainers could point me toward a test that does that, I can look at adding one.

@md5
Copy link
Contributor Author

md5 commented Sep 22, 2016

Another thing I didn't do in this PR was to update the generator code under src/main/ruby to reflect the change to use SimpleBuildStep.LastBuildAction.

@pkuczynski pkuczynski merged commit 80b170e into jenkinsci:master Sep 22, 2016
@md5 md5 deleted the pipeline branch September 22, 2016 18:28
@md5
Copy link
Contributor Author

md5 commented Sep 22, 2016

🤘

@pkuczynski
Copy link
Contributor

So I was finally able to deploy your PR into version 1.6.4. Took a while :)

As it turns out latest jenkins plugin requirements include FindBugs to pass, which in our case shows 31 errors. I silenced it for now and created #30. Unfortunately I am not a Java developer so I am not really able to fix this issues. Maybe you would like to help?

@tintht
Copy link

tintht commented May 19, 2017

Awesome when to know RubyMetrics-Plugin could work with pipeline but why you don't update how-to-work from readme.md, im lucky when reading changelog.md to know it could work with pipeline :)

BTW, thank you for this plugin.

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