Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-44848] Stop removing JobPropertys defined outside step
There's some special logic for handling the case where the previous run had the `properties` step run, but does not have the `JobPropertyTrackerAction` on it - i.e., the first run of an existing job with the `properties` step after upgrading. In that case, we still use the old behavior of removing all existing `JobProperty`s. But in all future runs, only `JobProperty`s defined via `properties` will be removed by `properties`. Also removed the warning messages about removing `JobProperty`s in non-multibranch jobs, since, well, we don't do that any more once this lands.
- Loading branch information
Showing
4 changed files
with
115 additions
and
67 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
44 changes: 44 additions & 0 deletions
44
src/main/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyTrackerAction.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,44 @@ | ||
package org.jenkinsci.plugins.workflow.multibranch; | ||
|
||
import hudson.model.InvisibleAction; | ||
import hudson.model.JobProperty; | ||
|
||
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nonnull; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* Invisible action used for tracking what {@link JobProperty}s were defined in the Jenkinsfile for a given run. | ||
*/ | ||
public class JobPropertyTrackerAction extends InvisibleAction { | ||
private final Set<String> jobPropertyDescriptors = new HashSet<>(); | ||
|
||
public JobPropertyTrackerAction(@CheckForNull List<JobProperty> jobProperties) { | ||
if (jobProperties != null) { | ||
for (JobProperty j : jobProperties) { | ||
jobPropertyDescriptors.add(j.getDescriptor().getId()); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Alternative constructor for copying an existing {@link JobPropertyTrackerAction}'s contents directly. | ||
* | ||
* @param copyFrom a non-null {@link JobPropertyTrackerAction} | ||
*/ | ||
public JobPropertyTrackerAction(@Nonnull JobPropertyTrackerAction copyFrom) { | ||
this.jobPropertyDescriptors.addAll(copyFrom.getJobPropertyDescriptors()); | ||
} | ||
|
||
public Set<String> getJobPropertyDescriptors() { | ||
return Collections.unmodifiableSet(jobPropertyDescriptors); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "JobPropertyTrackerAction[jobPropertyDescriptors:" + jobPropertyDescriptors + "]"; | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/resources/org/jenkinsci/plugins/workflow/multibranch/Messages.properties
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
ReadTrustedStep._has_been_modified_in_an_untrusted_revis=\u2018{0}\u2019 has been modified in an untrusted revision | ||
WorkflowMultiBranchProject.DisplayName=Multibranch Pipeline | ||
WorkflowMultiBranchProject.Description=Creates a set of Pipeline projects according to detected branches in one SCM repository. | ||
JobPropertyStep._could_remove_warning=WARNING: The 'properties' step will remove all 'JobProperty's currently configured in this job, \ | ||
either from the UI or from an earlier 'properties' step.\n\ | ||
This includes configuration for discarding old builds, parameters, concurrent builds and build triggers. | ||
JobPropertyStep._removed_property_warning=WARNING: Removing existing job property ''{0}'' |
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