Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use MultiBranchProject from Branch API Plugin to manage sub-projects.
Bump core dependency version to 1.625.1 to match Branch API Plugin and refactor TemplateDrivenMultiBranchProject significantly to use new APIs. Remove "Allow anonymous trigger of branch sync" setting Remove "Suppress automatic build trigger after discovering new branches" setting Add migration for SCMSource and build discarder.
- Loading branch information
1 parent
98a9910
commit 798be16
Showing
37 changed files
with
812 additions
and
888 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/main/java/com/github/mjdetullio/jenkins/plugins/multibranch/BranchProjectProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2016, Matthew DeTullio | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package com.github.mjdetullio.jenkins.plugins.multibranch; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.AbstractProject; | ||
import hudson.model.JobProperty; | ||
import hudson.model.JobPropertyDescriptor; | ||
import hudson.model.TopLevelItem; | ||
import jenkins.branch.Branch; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* A basic {@link JobProperty} that holds a {@link Branch} so that {@link TemplateDrivenMultiBranchProject}s can | ||
* manage the project holding this property. | ||
* | ||
* @author Matthew DeTullio | ||
*/ | ||
public class BranchProjectProperty<P extends AbstractProject<P, B> & TopLevelItem, B extends AbstractBuild<P, B>> | ||
extends JobProperty<P> { | ||
|
||
private Branch branch; | ||
|
||
/** | ||
* Creates a new property with the Branch it will hold. | ||
* | ||
* @param branch the branch | ||
*/ | ||
public BranchProjectProperty(@Nonnull Branch branch) { | ||
this.branch = branch; | ||
} | ||
|
||
/** | ||
* Gets the Branch held by the property. | ||
* | ||
* @return the branch | ||
*/ | ||
@Nonnull | ||
public Branch getBranch() { | ||
return branch; | ||
} | ||
|
||
/** | ||
* Sets the Branch held by the property. | ||
* | ||
* @param branch the branch | ||
*/ | ||
public void setBranch(@Nonnull Branch branch) { | ||
this.branch = branch; | ||
} | ||
|
||
/** | ||
* {@link BranchProjectProperty}'s descriptor. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Extension | ||
public static class DescriptorImpl extends JobPropertyDescriptor { | ||
@Override | ||
public String getDisplayName() { | ||
return "Branch"; | ||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...java/com/github/mjdetullio/jenkins/plugins/multibranch/FreeStyleBranchProjectFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2014-2015, Matthew DeTullio | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package com.github.mjdetullio.jenkins.plugins.multibranch; | ||
|
||
import hudson.Extension; | ||
import hudson.model.FreeStyleBuild; | ||
import hudson.model.FreeStyleProject; | ||
import hudson.model.Item; | ||
import jenkins.branch.Branch; | ||
import jenkins.branch.BranchProjectFactoryDescriptor; | ||
import jenkins.branch.MultiBranchProject; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* @author Matthew DeTullio | ||
*/ | ||
public final class FreeStyleBranchProjectFactory | ||
extends TemplateDrivenBranchProjectFactory<FreeStyleProject, FreeStyleBuild> { | ||
|
||
/** | ||
* No-op constructor used for data binding. | ||
*/ | ||
@DataBoundConstructor | ||
public FreeStyleBranchProjectFactory() { | ||
// No-op | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public FreeStyleProject newInstance(Branch branch) { | ||
FreeStyleProject project = new FreeStyleProject(getOwner(), branch.getEncodedName()); | ||
setBranch(project, branch); | ||
return project; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public boolean isProject(Item item) { | ||
return item instanceof FreeStyleProject && | ||
((FreeStyleProject) item).getProperty(BranchProjectProperty.class) != null; | ||
} | ||
|
||
/** | ||
* {@link TemplateDrivenBranchProjectFactory}'s descriptor. | ||
*/ | ||
@SuppressWarnings("unused") | ||
@Extension | ||
public static class DescriptorImpl extends BranchProjectFactoryDescriptor { | ||
@Override | ||
public String getDisplayName() { | ||
return "Fixed configuration"; | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(Class<? extends MultiBranchProject> clazz) { | ||
return FreeStyleMultiBranchProject.class.isAssignableFrom(clazz); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.