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 running promotions on inheritance projects. #75

Merged

Conversation

J-cztery
Copy link
Contributor

This pull request contains an implementation of extension point to jenkins-inheritance-project-plugin and some changes to JobPropertyImpl construction to allow for interaction with jenkins-inheritance-project-plugin.
A new constructor has been added that allows reading promotion processes information from the location specified by an existing JobPropertyImpl but makes the JobPropertyImpl instance (and it's promotion processes) independent otherwise.

Initially I wanted to keep this extension separate (as a plugin) but this proved too difficult because of the hermetization of JobPropertyImpl and its insistence on loading promotion processes on construction.

Note that there is a problem in jenkins-inheritance-project-plugin and there is an accompanying fix to jenkins-inheritance-project-plugin plugin. That problem prevents from seeing promotions that are currently running. There might be some problems with getting it merged to mainline, so you might want to use my fork directly https://github.com/J-cztery/jenkins-inheritance-plugin.

This change introduces optional dependency to jenkins-inheritance-project.

It supersedes the following pull requests:
#74
#51 (thanks David Tanner for inspiration).

if(subdirs!=null) {
loadProcesses(subdirs);
}
private void loadProcesses(File[] subdirs) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

tab/spaces mix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Thanks.

@oleg-nenashev
Copy link
Member

@J-cztery Thanks for taking an action! the selected approach looks to be valid to me. From what I see the issue in inheritance plugin is not a blocker for this PR. Is it correct?

It would be also great to have a functional test verifying the new functionality

});

loadProcesses(subdirs);
}
Copy link
Member

Choose a reason for hiding this comment

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

Mostly duplicates init(). Would be great to merge methods somehow

@J-cztery
Copy link
Contributor Author

@oleg-nenashev: Thank you for the code review. I will work on your comments next. And yes, this change will make promotions usable without the change to jenkins-inheritance-plugin(but with some nuisances).

@J-cztery
Copy link
Contributor Author

@oleg-nenashev: regarding the test. I struggle to write an unit tests that uses multiple plugins. Any ideas on how to set it up?

@J-cztery
Copy link
Contributor Author

Yeah, I have just tested this fix with 1.5.3 version of inheritance build and the only problem i could find is that when the promotion build is running it is not shown on Promotion Status in either build context or project context. But it is shown in the queue.
The problem is due to the fact that inheritance plugin does not cache properties and generate properties on the fly and it so it generates many JobPropertyImpls....
I do not think this one is critical for the PR.

@oleg-nenashev
Copy link
Member

@J-cztery
Thanks for the changes. The code looks good to me.
Inheritance plugin was in my personal blacklist for a long time due to functional issues, so unfortunately I'm not very familiar with its testing capabilities. BTW, in @JenkinsRule you will automatically get optional plugins installed by default. So you would be able to write a test there. If you describe the reproduction scenario, I probably can write a sample test.

Would you like to keep the test as a part of this PR? If no, I could merge this commit in order to test the behavior together with other changes.

@J-cztery
Copy link
Contributor Author

@oleg-nenashev :
Thank you for reviewing this PR!
I have currently issues with running tests on Windows as this is my environment of choice.
CallStack.txt
I will try to get them working but this might take time.

If you would like to create a test then a scenario is :

  1. Create an inheritance project BASE and add jobPropertyImpl with a promotion.
  2. Create an inheritance project DERIVED and add a project reference (Ordered or Simple) to project BASE.
  3. Now if you build DERIVED and if promotion works (does not crash) then it works ;)
    So if you find time to write this test then ok, otherwise i will do it.

I do observe some functional issues with inheritance plugin as well but i am trying to kill them one by one. The problem i see with this plugin is that maintainer is not very responsive and the project is pretty much dead;(

What are your main concerns regarding the functionality of inheritance plugin?
I have added:

  1. ability to specify node(label) of transient projects(in mating),
  2. View full build flow actually shows full build flow.
  3. Block when upstream and downstream project is building is now working.
  4. Got parametrized trigger plugin working so that upstream/downstream relationship can be parameterized.
  5. Added support to choose priorities of parents of transient projects(in mating)
  6. Changed the way inheritance project decides if it should do full inheritance to blacklisting.
  7. Recently added caching of properties (This is the thing that promotion-plugin needs).

@oleg-nenashev
Copy link
Member

@J-cztery
this is a known issue with Windows tests on old Jenkins versions (locking of tmp dirs). You could run tests locally against new Jenkins core versions, then PR builder will run them against the actual version if you don't commit the version change.

We could also fork the Inheritance project plugin to jenkinsci org if @HedAurabesh wants to handover it. Maybe makes sense to start a thread in jenkinsci-dev and Cc owners there. The plugin is definitely useful, so it it great that somebody works on it.

@J-cztery
Copy link
Contributor Author

@oleg-nenashev : Thanks for the hint. I will try to run tests against newer version of Jenkins. I have adapted one of the tests to use inheritance project but it would make sense(?) to run most of them if not all against FreeStyle project type as well as InheritanceProject. This would require making the unit tests slightly more complex...Do you think it would be worth it?

Let's deal with potential fork of inheritance project once this PR is finished.

@oleg-nenashev
Copy link
Member

@J-cztery
Makes sense to create new tests instead of modifying the existing ones. But feel free to copy as much tests as you want if it allows to increase the coverage :)

For such integrations it also makes sense to create a spot-check in https://github.com/jenkinsci/acceptance-test-harness in order to catch regressions in Jenkins core, but it is optional && can be done after this PR.

@oleg-nenashev
Copy link
Member

Performed manual spot-check and it seems to work.
Excluding it from the today's release to have a deeper look

@J-cztery
Copy link
Contributor Author

Yeah.. I am still working on the unit tests and realized that @DavidTanner's change will still be needed (slightly modified to keep the binary compatibility as you requested) and i am not sure if i will be able to get unit tests working with inheritance-plugin 1.53.
So not releasing it just yet makes sense. I will let you know once i am done with tests.

1. Add unit tests.
2. Remove assert from PromotionProcess as in InheritanceProject it no longer holds.
3. Try to resolve build from jobName and build number first and if this fails, try others.
4. Implement an extension for inheritance-plugin
@J-cztery J-cztery force-pushed the INHERITANCE_PROJECTS_SUPPORT branch 2 times, most recently from f8646cb to 1b5f7e6 Compare November 26, 2015 10:34
@J-cztery
Copy link
Contributor Author

Ready @oleg-nenashev.

@oleg-nenashev
Copy link
Member

👍

@oleg-nenashev
Copy link
Member

@J-cztery thanks a lot for your efforts!

@oleg-nenashev oleg-nenashev added this to the 2.25 milestone Dec 11, 2015
@jenkinsadmin
Copy link
Member

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

oleg-nenashev added a commit that referenced this pull request Feb 18, 2016
Add support for running promotions on inheritance projects.
@oleg-nenashev oleg-nenashev merged commit 828da6d into jenkinsci:master Feb 18, 2016
@J-cztery J-cztery deleted the INHERITANCE_PROJECTS_SUPPORT branch March 30, 2016 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants