|
109 | 109 | import java.util.logging.Logger; |
110 | 110 | import java.util.stream.Collectors; |
111 | 111 | import jenkins.console.WithConsoleUrl; |
| 112 | +import jenkins.model.FullyNamed; |
| 113 | +import jenkins.model.FullyNamedModelObject; |
112 | 114 | import jenkins.model.Jenkins; |
113 | 115 | import jenkins.model.queue.AsynchronousExecution; |
114 | 116 | import jenkins.model.queue.CompositeCauseOfBlockage; |
@@ -1882,7 +1884,7 @@ public interface NonBlockingTask extends Task {} |
1882 | 1884 | * design, a {@link Task} must have at least one sub-task.) |
1883 | 1885 | * Most of the time, the primary subtask is the only sub task. |
1884 | 1886 | */ |
1885 | | - public interface Task extends ModelObject, SubTask { |
| 1887 | + public interface Task extends FullyNamedModelObject, SubTask { |
1886 | 1888 | /** |
1887 | 1889 | * Returns true if the execution should be blocked |
1888 | 1890 | * for temporary reasons. |
@@ -1928,21 +1930,22 @@ default CauseOfBlockage getCauseOfBlockage() { |
1928 | 1930 | */ |
1929 | 1931 | String getName(); |
1930 | 1932 |
|
1931 | | - /** |
1932 | | - * @see hudson.model.Item#getFullDisplayName() |
1933 | | - */ |
1934 | | - String getFullDisplayName(); |
1935 | | - |
1936 | 1933 | /** |
1937 | 1934 | * Returns task-specific key which is used by the {@link LoadBalancer} to choose one particular executor |
1938 | 1935 | * amongst all the free executors on all possibly suitable nodes. |
1939 | 1936 | * NOTE: To be able to re-use the same node during the next run this key should not change from one run to |
1940 | 1937 | * another. You probably want to compute that key based on the job's name. |
1941 | 1938 | * |
1942 | | - * @return by default: {@link #getFullDisplayName()} |
| 1939 | + * @return by default: {@link FullyNamed#getFullName()} if implements {@link FullyNamed} or {@link #getFullDisplayName()} otherwise. |
1943 | 1940 | * @see hudson.model.LoadBalancer |
1944 | 1941 | */ |
1945 | | - default String getAffinityKey() { return getFullDisplayName(); } |
| 1942 | + default String getAffinityKey() { |
| 1943 | + if (this instanceof FullyNamed fullyNamed) { |
| 1944 | + return fullyNamed.getFullName(); |
| 1945 | + } else { |
| 1946 | + return getFullDisplayName(); |
| 1947 | + } |
| 1948 | + } |
1946 | 1949 |
|
1947 | 1950 | /** |
1948 | 1951 | * Checks the permission to see if the current user can abort this executable. |
|
0 commit comments