diff --git a/src/main/java/hudson/plugins/promoted_builds/Promotion.java b/src/main/java/hudson/plugins/promoted_builds/Promotion.java index 52cbce99..140bd5f4 100644 --- a/src/main/java/hudson/plugins/promoted_builds/Promotion.java +++ b/src/main/java/hudson/plugins/promoted_builds/Promotion.java @@ -157,8 +157,8 @@ public EnvVars getEnvironment(TaskListener listener) throws IOException, Interru return e; } - - + + /** * Get a user name of the person, who triggered the promotion. * The method tries various sources like {@link UserIdCause} or {@link ManualCondition.Badge}. @@ -180,7 +180,7 @@ public String getUserName() { return nameFromUserIdCause; } - //fallback to badge lookup for compatibility + //fallback to badge lookup for compatibility for (PromotionBadge badget : getStatus().getBadges()) { if (badget instanceof ManualCondition.Badge) { final String nameFromBadge = ((ManualCondition.Badge) badget).getUserName(); @@ -191,14 +191,14 @@ public String getUserName() { } return Jenkins.ANONYMOUS.getName(); } - + /** * Gets ID of the {@link User}, who triggered the promotion. * The method tries various sources like {@link UserIdCause} or {@link ManualCondition.Badge}. * @return ID of the user who triggered the promotion. * If the search fails, returns ID of {@link User#getUnknown()}. - * @since 2.22 + * @since 2.22 */ @Nonnull public String getUserId() { @@ -218,7 +218,7 @@ public String getUserId() { return idFromUserIdCause; } - //fallback to badge lookup for compatibility + //fallback to badge lookup for compatibility for (PromotionBadge badget : getStatus().getBadges()) { if (badget instanceof ManualCondition.Badge) { final String idFromBadge = ((ManualCondition.Badge) badget).getUserId(); @@ -231,7 +231,7 @@ public String getUserId() { } public List getParameterValues(){ - List values=new ArrayList(); + List values=new ArrayList(); ParametersAction parametersAction=getParametersActions(this); if (parametersAction!=null){ ManualCondition manualCondition=(ManualCondition) getProject().getPromotionCondition(ManualCondition.class.getName()); @@ -244,8 +244,8 @@ public List getParameterValues(){ } return values; } - - //fallback to badge lookup for compatibility + + //fallback to badge lookup for compatibility for (PromotionBadge badget:getStatus().getBadges()){ if (badget instanceof ManualCondition.Badge){ return ((ManualCondition.Badge) badget).getParameterValues(); @@ -253,7 +253,7 @@ public List getParameterValues(){ } return Collections.emptyList(); } - + /** * Gets parameter definitions from the {@link ManualCondition}. * @return List of parameter definitions to be presented. @@ -266,7 +266,7 @@ public List getParameterDefinitionsWithValue(){ if (manualCondition == null) { return definitions; } - + for (ParameterValue pvalue:getParameterValues()){ ParameterDefinition pdef=manualCondition.getParameterDefinition(pvalue.getName()); if (pdef == null) { @@ -286,11 +286,11 @@ public void run() { protected class RunnerImpl extends AbstractRunner { final Promotion promotionRun; - + RunnerImpl(final Promotion promotionRun) { this.promotionRun = promotionRun; } - + @Override protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException { String customWorkspace = Promotion.this.getProject().getCustomWorkspace(); @@ -303,13 +303,13 @@ protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedExc return Lease.createDummyLease( rootPath.child(getEnvironment(listener).expand(customWorkspace))); } - + TopLevelItem item = (TopLevelItem)getTarget().getProject(); FilePath workspace = n.getWorkspaceFor(item); if (workspace == null) { throw new IOException("Cannot retrieve workspace for " + item + " on the node " + n); } - return wsl.acquire(workspace, true); + return wsl.allocate(workspace, promotionRun); } protected Result doRun(BuildListener listener) throws Exception { @@ -326,10 +326,10 @@ protected Result doRun(BuildListener listener) throws Exception { if(!preBuild(listener,project.getBuildSteps())) return Result.FAILURE; - + try { List params=getParameterValues(); - + if (params!=null){ for(ParameterValue value : params) { BuildWrapper wrapper=value.createBuildWrapper(Promotion.this); @@ -341,20 +341,20 @@ protected Result doRun(BuildListener listener) throws Exception { } } } - + if(!build(listener,project.getBuildSteps(),target)) return Result.FAILURE; - + return null; } finally { boolean failed = false; - + for(int i = buildEnvironments.size()-1; i >= 0; i--) { if (!buildEnvironments.get(i).tearDown(Promotion.this,listener)) { failed=true; } } - + if(failed) return Result.FAILURE; } @@ -419,7 +419,7 @@ private boolean preBuild(BuildListener listener, List steps) { } return true; } - + } public static final PermissionGroup PERMISSIONS = new PermissionGroup(Promotion.class, Messages._Promotion_Permissions_Title()); @@ -441,9 +441,9 @@ public boolean equals(Object obj) { final Promotion other = (Promotion) obj; return this.getId().equals(other.getId()); } - - - + + + /** * Factory method for creating {@link ParametersAction} * @param parameters @@ -462,7 +462,7 @@ public static ParametersAction getParametersActions(Promotion build){ * @param build * @param promotionParams */ - public static void buildParametersAction(@Nonnull List actions, + public static void buildParametersAction(@Nonnull List actions, @Nonnull AbstractBuild build, @CheckForNull List promotionParams) { if (promotionParams == null) { @@ -470,7 +470,7 @@ public static void buildParametersAction(@Nonnull List actions, } List params=new ArrayList(); - + //Add the target build parameters first, if the same parameter is not being provided bu the promotion build List parameters = build.getActions(ParametersAction.class); for(ParametersAction paramAction:parameters){ @@ -480,10 +480,10 @@ public static void buildParametersAction(@Nonnull List actions, } } } - + //Add all the promotion build parameters params.addAll(promotionParams); - + // Create list of actions to pass to scheduled build actions.add(new ParametersAction(params)); }