Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Conversation

balihb
Copy link
Contributor

@balihb balihb commented Oct 27, 2016

This is a very rough Jenkins Pipeline support with code duplication that should somehow be refactored.
An example of such pipeline is like this:
Jenkinsfile.txt

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 90.962% when pulling 6170fa8 on balihb:master2 into 7fe94de on uber:master.

@ascandella
Copy link
Contributor

Very cool! Is there some way for me to test this? I've never used jenkinsfile/pipeline before

@balihb
Copy link
Contributor Author

balihb commented Oct 28, 2016

there is a repository here with the proper Jenkinsfile:
https://github.com/balihb/boot-react/blob/master/Jenkinsfile
The check step is currently failing, so I can test build failure. I'm currently using staging area for code review. I haven't modified the Phabricator build wrapper to work with Jenkins Pipeline.
I have the following build plan step in Harbormaster (make http request):
https://myci/buildByToken/buildWithParameters?job=${repository.callsign}_review&DIFF_ID=${buildable.diff}&PHID=${target.phid}&token=mytoken&STREF=${repository.staging.ref}
The job is configured as a pipeline job, with the post parameters as build parameters and the following SCM config:
jppconfig

@ascandella
Copy link
Contributor

Ok, so it sounds like this is still a Work-In-Progress commit then, I'll add a WIP label and then ping me when this is ready for review.

@aadis
Copy link

aadis commented Jan 19, 2017

We'd be interested in this as well.

@balihb
Copy link
Contributor Author

balihb commented Jan 24, 2017

I'll update the PR as soon as I can.
Some notes:

  • no wrapper support, just notification (might be possible, never tried)
  • no coverage support since cobertura has no pipeline support. for now and the type hierarchy stops the plugin to support coverage (run vs abstractbuild. let me know if anyone knows a solution) (also refer to: JENKINS-30700 / #50 Jenkins pipeline support jenkinsci/cobertura-plugin#55 )
  • introducing pipeline tests is a whole bunch of big work in itself, so it might take a while wile I can produce more than just some self tested code

@aadis
Copy link

aadis commented Jan 24, 2017

As you mentioned the cobertura plugin is right now seeing active work on pipeline support. The PR#55 builds and works.

It might be a good idea to test against that (or I can do the testing & report back if you update this PR)

@CLAassistant
Copy link

CLAassistant commented Jan 31, 2017

CLA assistant check
All committers have signed the CLA.

@balihb balihb force-pushed the master2 branch 2 times, most recently from d4ac341 to 28dacfb Compare January 31, 2017 15:32
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 91.139% when pulling 28dacfb on balihb:master2 into 65de8c0 on uber:master.

@balihb
Copy link
Contributor Author

balihb commented Jan 31, 2017

The solution is getting more and more hacky. I can't exactly base a PR on an unreleased dependency.
So still only notification support.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 91.139% when pulling 28dacfb on balihb:master2 into 65de8c0 on uber:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 91.139% when pulling 28dacfb on balihb:master2 into 65de8c0 on uber:master.

@balihb
Copy link
Contributor Author

balihb commented Feb 1, 2017

@sectioneight if I create proper pipeline tests would this PR be eligible for merging into master? There is still no coverage and build wrapper support, but it would be great have the basic pipeline support in the released plugin.

@ascandella
Copy link
Contributor

ascandella commented Feb 1, 2017 via email

@ascandella
Copy link
Contributor

Oh, i see, we already have a PR :) I was assuming this was an issue while responding via email.

Would you like us to take a look at this now or are there changes forthcoming?

@hanjunx
Copy link

hanjunx commented Feb 2, 2017 via email

@cmmata
Copy link

cmmata commented May 23, 2017

Is this PR still valid?

@balihb
Copy link
Contributor Author

balihb commented May 29, 2017

it is valid. I just haven't had the time to write the tests for it.

@aadis
Copy link

aadis commented Jul 11, 2017

jenkinsci/cobertura-plugin#55 has been merged, so it'd be great if this PR can make sure cobertura support is enabled.

We're using this PR directly, and other than the coverage reporting/comparison, it's been working great!

@julienmathevet
Copy link

+1

@balihb balihb changed the title basic Jenkins pipeline support for notifier (removed code duplication) basic Jenkins pipeline support for notifier Oct 31, 2017
@balihb
Copy link
Contributor Author

balihb commented Oct 31, 2017

I finally had time to finish this up. Please try it out!
I want to follow it up with a few more PR like wrapper support and pipeline dsl support among others.

@coveralls
Copy link

coveralls commented Oct 31, 2017

Coverage Status

Coverage decreased (-0.1%) to 90.619% when pulling 9a8b6a3 on balihb:master2 into 99a4231 on uber:master.

@balihb
Copy link
Contributor Author

balihb commented Nov 2, 2017

@sectioneight ping :D

@ascandella
Copy link
Contributor

@balihb I'm not working on this anymore, perhaps @jjx could take a look or knows somebody who's current?

@balihb
Copy link
Contributor Author

balihb commented Nov 14, 2017

maybe @artms as the latest commiter?

@sascha-egerer
Copy link

Just did a test and works fine here. This is my Jenkinsfile

pipeline {
  agent any
  parameters {
    string(name: 'PHID', defaultValue: '', description: '')
    string(name: 'DIFF_ID', defaultValue: '', description: '')
  }
  stages {
    stage('build') {
      steps {
        sh 'echo foo'
      }
    }
  }
  post {
    always {
        script {
            // workaround. Seems to be a bug!?
            currentBuild.result = currentBuild.currentResult
        }
        step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true])
    }
  }
}

@youngmit
Copy link
Contributor

Where does this stand? We would also really appreciate this PR getting merged. It has a "work in progress" tag; is this still WIP? Perhaps removing that tag would help to get the attention of the maintainers, as it appears to be ready for review. @sectioneight seemed initially enthusiastic about this PR, but is apparently no longer involved in maintaining the project. Who are the current maintainers?

@balihb
Copy link
Contributor Author

balihb commented May 14, 2018 via email

@kageiit
Copy link
Contributor

kageiit commented May 14, 2018

Im ok merging this if its been staged and working without breaking backwards compatibility

@kageiit
Copy link
Contributor

kageiit commented May 14, 2018

@balihb please sign the CLA before we can merge this

@kageiit
Copy link
Contributor

kageiit commented May 14, 2018

@balihb Can you please also add some documentation to the advanced section

@balihb
Copy link
Contributor Author

balihb commented May 15, 2018

I've added a fix for the null pointer exception in the pipeline.
Docs is in progress.

@sascha-egerer
Copy link

@balihb could you please take a look at my Jenkinsfile i've posted above? Is it possible to fix that issue the workaround is required for? currentBuild.result is empty and is copied from currentBuild.currentResult in my Jenkinsfile.

@balihb
Copy link
Contributor Author

balihb commented May 15, 2018

it should be fixed by my latest change.


optionalJenkinsPlugins 'org.jenkins-ci.plugins:junit:1.6@jar'
optionalJenkinsPlugins 'org.jenkins-ci.plugins:cobertura:1.9.6@jar'
optionalJenkinsPlugins 'org.jenkins-ci.plugins:cobertura:1.11@jar'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this required? Can we decouple this change?

Choose a reason for hiding this comment

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

Answered in #185 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

@balihb
Copy link
Contributor Author

balihb commented May 15, 2018 via email

@balihb
Copy link
Contributor Author

balihb commented May 16, 2018

documentation added. Hope it is ok. let me know if I should change anything about it.


public Result getBuildResult() {
return this.build.getResult();
if (this.build.getResult() == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why we would want to return success on null? It seems a bit counterintuitive. Are there any api docs defining this new behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on oldschool freestyle jobs after the build reached the last build step it set the build result to success, but in pipeline there is no definite end of build blocks, so it won't explicitly set SUCCESS, hence the previous workaround, where it was needed to run this before the notifier:

currentBuild.result = currentBuild.result ?: 'SUCCESS'

Copy link
Contributor

Choose a reason for hiding this comment

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

The phab notifier build step need not necessarily be the last step. If someone uses pipeline and not this plugin, they would have to workaround this anyways, so this logic should not be in this plugin. This should be reported upstream to jenkins.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

null == success so far. IMHO it was a genuine missing null check in the plugin code. In freestyle it is always set and in pipeline it is always considered SUCCESS.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense

resultProcessor.sendComment(commentWithConsoleLinkOnFailure);

return true;
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

can remove this redundant return at the end of a void method


// Fallback to scanning for the reports
copyCoverageToJenkinsMaster(build);
copyCoverageToJenkinsMaster(build, workspace);
Copy link
Contributor

Choose a reason for hiding this comment

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

just inline build.getWorkspace() here and avoid the local workspace variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the new Jenkins API you can't use Build, but must use Run, but the run interface won't provide a getWorkspace method. I can change this call to this:

copyCoverageToJenkinsMaster(build, getWorkspace());

but this is the best I can do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets leave it as is then


public Result getBuildResult() {
return this.build.getResult();
if (this.build.getResult() == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense

@kageiit kageiit merged commit 93043b1 into uber-archive:master May 16, 2018
@khawaga
Copy link

khawaga commented May 16, 2018

Any ETA on when this will be available (plugin version update)?

@arcadien
Copy link

Up? everyting seems ready? Please at least allow us to download the plugin from Travis integration server, thanks

@kageiit
Copy link
Contributor

kageiit commented Jun 12, 2018

You can use ./gradlew jpi to build the plugin locally till a release is cut

@arcadien
Copy link

arcadien commented Jun 12, 2018 via email

@bhush9
Copy link

bhush9 commented Jun 30, 2018

Hi,

We in KDE would very much like to use this on our build servers, is there any chance to get it released under plugin upgrades as we'd rather use it from released version instead of unstable git builds.

Thanks.

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

Successfully merging this pull request may close these issues.