nemccarthy / stash-pullrequest-builder-plugin

A Jenkins plugin for Building Stash Pull Requests
https://wiki.jenkins-ci.org/display/JENKINS/Stash+pullrequest+builder+plugin
Other
64 stars 130 forks source link

Add support for Jenkins Pipeline. #110

Closed stebadge closed 7 years ago

stebadge commented 7 years ago

Before this commit, if you attempted to use the Stash pull-request builder plug in with Jenkins Pipeline, you would encounter an error. Ultimately, this error was due to the fact that this plug in require jobs to use the AbstractProject base class, but the Jenkins Pipeline job class (WorkflowJob) doesn't.

The good news is that WorkflowJob and AbstractProject share a base class of Job, and that most functionality of this plug in can be made available to WorkflowJob refactoring uses of AbstractProject to uses of Job instead. For cases where this does not provide enough functionality, there are interfaces implemented in common by both (ParameterizedJobMixIn.ParameterizedJob, Queue.Task) that fill the gaps.

The one remaining piece of functionality this commit does not extend to be available to Jenkins Pipeline is custom post-build comments, so a TODO to that effect was added.

dalewking commented 7 years ago

Can we get a release for this?

zeton3 commented 7 years ago

HI, When it can be released?

kikuingithub commented 7 years ago

Hi, Can we get a release of this.. with support for pipeline ?

bcfisher commented 7 years ago

Is there a reason this hasn't been released? @nemccarthy

praveen12bnitt commented 7 years ago

@stebadge Do you mind sharing a sample jenkinsfile using this plugin? It will be useful for others too . I will add the details to the ReadMe once i have it working.

bcfisher commented 7 years ago

It's not really about the jenkins file @praveen12bnitt . You can use any jenkinsFile you please.

bcfisher commented 7 years ago

I ended up taking the fixes, building them locally and then installing it to my jenkins box manually, as many others mentioned above. It seems to work great for me. I'd prefer to use hooks, but, I haven't the allotted time to upgrade the plugin.

eabern2 commented 6 years ago

@stebadge @bcfisher Can you share how you used this in pipeline? I'm trying to use it in the properties step in pipelineTrigger as the pipeline code generator syntax states, but I'm getting an error:

Caused: java.lang.IllegalArgumentException: Could not instantiate {triggers={$class=StashBuildTrigger, projectPath=, cron= *, stashHost=xxxxxxxxxx, credentialsId=xxxxxxxxxxxx, projectCode=xxxxxxxx, repositoryName=env.GIT_URL, ciSkipPhrases=NO TEST, ciBuildPhrases=test this please, ignoreSsl=false, checkDestinationCommit=false, checkMergeable=false, mergeOnSuccess=false, checkNotConflicted=false, onlyBuildOnComment=false, deletePreviousBuildFinishComments=false, cancelOutdatedJobsEnabled=false}} ...

This is the code I have in properties

pipelineTriggers([stashBuildTrigger(projectPath: '', cron: ' ', stashHost: xxxxx', credentialsId: 'xxxxxxxx', projectCode: 'xxxxx' /"${project_name}"*/, repositoryName: 'env.GIT_URL', ciSkipPhrases: 'NO TEST', ciBuildPhrases: 'test this please', ignoreSsl: false, checkDestinationCommit: false, checkMergeable: false, mergeOnSuccess: false, checkNotConflicted: false, onlyBuildOnComment: false, deletePreviousBuildFinishComments: false, cancelOutdatedJobsEnabled: false)])])

bcfisher commented 6 years ago

I didn't add it to the jenkinsFile, but instead, from the ui.

eabern2 commented 6 years ago

@bcfisher Oh Ok. Was it in the UI of the multibranch pipeline job? I tried that but got a class cast exception.

bcfisher commented 6 years ago

no, just a pipeline job image

bcfisher commented 6 years ago

and then in the pipeline job, I configured the stash pull request builder there. E.g. image

kikuingithub commented 6 years ago

Had any one run the latest version of master successfully ? Looking for release that supports pipeline.

eabern2 commented 6 years ago

@kikuingithub yeah it works. But it doesn't work with the multibranch pipeline job.

I switched over to pipeline job but I still need regular branches to build and so far I have not been able to get the job to work to build both PRs and branches. If anyone has any insight let me know.

wburgers commented 6 years ago

Anybody else having problems aborting running pipeline jobs? We have turned on the option "Rebuild if destination branch changes" together with "Cancel outdated jobs". When the destination branch changes, it triggers new pipeline builds, which is correct, but the outdated builds don't abort.

To be clear, we run the non-released version of the plug-in, in which pipeline jobs are supported.

SwagMuffinMcYoloPants commented 6 years ago

Was this released yet as an official version? If not, is there a planned date?

proski commented 5 years ago

I have submitted a PR for the current code, please see https://github.com/jenkinsci/stash-pullrequest-builder-plugin/pull/69