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

[JENKINS-17680] Upgrade configurations from version 1.25 #23

Merged
merged 7 commits into from
Aug 8, 2013

Conversation

ikedam
Copy link
Member

@ikedam ikedam commented Jul 27, 2013

Upgrading CopyArtfifact from 1.25 or earlier to 1.26 or later causes job names to copy from get empty in job configuration pages.
Running a build upgrades the configuration, but the configuration breaks if one opens the configuration page and save it before running a build.

With this patch, configurations are upgraded when they are loaded.

This works as following:

  • When a instance of CopyArtifact is unmarshalled, tests whether upgrade is needed.
  • If any instance of CopyArtifact are needed to be upgrade, scan for all jobs and perform upgrade all CopyArtifact.

Points are:

  • I did not persist the flag whether upgrading all CopyArtifact is done, for the case that a job with a old version of CopyArtifact configuration is recovered from a backup.
  • I did not remove existing codes that upgrade configurations when running a build. There may be a case scanning for CopyArtifact fails. For example, CopyArtifact is wrapped by another Builder.

@buildhive
Copy link

Jenkins » copyartifact-plugin #50 UNSTABLE
Looks like there's a problem with this pull request
(what's this?)

@jenkinsadmin
Copy link
Member

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

@ikedam
Copy link
Member Author

ikedam commented Jul 28, 2013

I could not reproduce the test failure.
It happens in new CLI(getURL()), and seems not caused by my change.


boolean isUpgraded = false;
for (Project<?,?> project: Jenkins.getInstance().getAllItems(Project.class)) {
for (CopyArtifact target: Util.filter(project.getBuilders(), CopyArtifact.class)) {
Copy link
Member

Choose a reason for hiding this comment

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

This will not work for a MatrixProject. Use getCopiers instead. (Which reminds me why the call to upgradeIfNecessary will still be necessary from perform: in case the build step is part of an AbstractProject which is neither a Project nor a MatrixProject.)

@buildhive
Copy link

Jenkins » copyartifact-plugin #52 SUCCESS
This pull request looks good
(what's this?)

@ikedam
Copy link
Member Author

ikedam commented Aug 3, 2013

@jglick Thank you for your reviewing. I updated the request.

  • Use @Initialize instead of ItemListener.onLoad
  • Use getCopiers to be able to apply to MatrixProject.
    • Added a test to verify it works properly with MatrixProject.

And I added a test testWrappedCopierProjectNameSplit for upgradeIfNecessary from perform.

I made so many changes that commit logs are dirty.
Should I create another pull request for merging after reviewing?

((MatrixProject)project).getBuildersList() : null);
if (list == null) return Collections.emptyList();
List<CopyArtifact> copiers = list.getAll(CopyArtifact.class);
List<CopyArtifact> copiers = CopyArtifact.getCopiers(project);
Copy link
Member Author

Choose a reason for hiding this comment

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

Existing getCopiers is CopyArtifact$ListenerImpl.getCopiers.
I extracted partially as CopyArtifact.getCopiers.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, though to reduce confusion it would be wise to pick different names for the two methods.

@ikedam
Copy link
Member Author

ikedam commented Aug 3, 2013

Changes in testProjectNameSplit.zip:

  • added matrix-copier that is MatrixProject and uses CopyArtifact.

new file testWrappedCopierProjectNameSplit.zip:

  • A project using CopyArtifact wrapped by another builder.
    • This is a case with [Conditional BuildStep Plugin|https://wiki.jenkins-ci.org/display/JENKINS/Conditional+BuildStep+Plugin]

assertFalse(configXml, configXml.contains("<projectName>"));
// When a project is specified with a variable, it is split improperly.
assertTrue(configXml, configXml.contains("<project>matrix</project>"));
assertTrue(configXml, configXml.contains("<parameters>which=${which}</parameters>"));
Copy link
Member Author

Choose a reason for hiding this comment

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

@jglick
Copy link
Member

jglick commented Aug 5, 2013

Should I create another pull request for merging after reviewing?

I see no need to rebase this way. Who cares how many commits it took so long as the end result is right?

@ikedam
Copy link
Member Author

ikedam commented Aug 8, 2013

@jglick Thanks for your reviewing.
I fixed what you pointed.

ikedam added a commit that referenced this pull request Aug 8, 2013
[JENKINS-17680] Upgrade configurations from version 1.25
@ikedam ikedam merged commit f13ba75 into jenkinsci:master Aug 8, 2013
@buildhive
Copy link

Jenkins » copyartifact-plugin #55 UNSTABLE
Looks like there's a problem with this pull request
(what's this?)

@ikedam
Copy link
Member Author

ikedam commented Aug 8, 2013

Hmmm.... Why this failure is reproduced?

@ikedam
Copy link
Member Author

ikedam commented Aug 8, 2013

It succeeded in the following test...so seems no problem.
https://buildhive.cloudbees.com/job/jenkinsci/job/copyartifact-plugin/org.jenkins-ci.plugins$copyartifact/56/

@ikedam
Copy link
Member Author

ikedam commented Aug 11, 2013

Thank you.
I also found unnecessary import, fixed them in f468296 .

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