-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for running promotions on inheritance projects (squashed)
- Loading branch information
Showing
3 changed files
with
102 additions
and
17 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
67 changes: 67 additions & 0 deletions
67
src/main/java/hudson/plugins/promoted_builds/inheritance/JobPropertyImplSelector.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,67 @@ | ||
|
||
package hudson.plugins.promoted_builds.inheritance; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import hudson.Extension; | ||
import hudson.model.JobProperty; | ||
|
||
import hudson.plugins.project_inheritance.projects.InheritanceProject; | ||
import hudson.plugins.project_inheritance.projects.inheritance.InheritanceSelector; | ||
|
||
import hudson.plugins.promoted_builds.JobPropertyImpl; | ||
|
||
/** | ||
* | ||
* @author Jacek Tomaka | ||
* @since TODO | ||
*/ | ||
@Extension(optional=true) | ||
public class JobPropertyImplSelector extends InheritanceSelector<JobProperty<?>> { | ||
private static final long serialVersionUID = 1L; | ||
private static final Logger logger = Logger.getLogger(JobPropertyImplSelector.class); | ||
|
||
@Override | ||
public boolean isApplicableFor(Class<?> clazz){ | ||
return JobProperty.class.isAssignableFrom(clazz); | ||
} | ||
|
||
@Override | ||
public InheritanceSelector.MODE getModeFor(Class<?> clazz){ | ||
if (JobPropertyImpl.class.isAssignableFrom(clazz)) return MODE.USE_LAST; | ||
return MODE.NOT_RESPONSIBLE; | ||
} | ||
|
||
@Override | ||
public String getObjectIdentifier(JobProperty<?> obj){ | ||
if ( obj!=null && JobPropertyImpl.class.getName().equals(obj.getClass().getName())){ | ||
return JobPropertyImplSelector.class.getName(); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public JobPropertyImpl merge(JobProperty<?> prior, JobProperty<?> latter, InheritanceProject caller){ | ||
return null; | ||
} | ||
|
||
@Override | ||
public JobProperty<?> handleSingleton(JobProperty<?> jobProperty, InheritanceProject caller){ | ||
if (jobProperty == null || caller == null) return jobProperty; | ||
if (caller.isAbstract) return jobProperty; | ||
|
||
if (!JobPropertyImpl.class.isAssignableFrom(jobProperty.getClass())) return jobProperty; | ||
|
||
|
||
JobPropertyImpl jobPropertyImpl = (JobPropertyImpl)jobProperty; | ||
|
||
try { | ||
JobPropertyImpl newJobProperty = new JobPropertyImpl(jobPropertyImpl, caller); | ||
return newJobProperty; | ||
} catch (Exception ex){ | ||
logger.error("Error during hacking up JobPropertyImpl", ex ); | ||
} | ||
return jobProperty; | ||
} | ||
} | ||
|