Skip to content

Commit

Permalink
Merge branch 'update-forms' into update-forms-2
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Jan 26, 2022
2 parents ea31794 + 7540afd commit d0f9acc
Show file tree
Hide file tree
Showing 42 changed files with 259 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# Drafts your next Release notes as Pull Requests are merged into "master"
- name: Generate GitHub Release Draft
id: release-drafter
uses: release-drafter/release-drafter@v5.15.0
uses: release-drafter/release-drafter@v5.17.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Generates a YAML changelog file using https://github.com/jenkinsci/jenkins-core-changelog-generator
Expand Down
7 changes: 1 addition & 6 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ THE SOFTWARE.

<properties>
<asm.version>9.2</asm.version>
<slf4jVersion>1.7.32</slf4jVersion>
<slf4jVersion>1.7.33</slf4jVersion>
<stapler.version>1638.v229a_24fa_b_17c</stapler.version>
<groovy.version>2.4.21</groovy.version>
</properties>
Expand Down Expand Up @@ -319,11 +319,6 @@ THE SOFTWARE.
<artifactId>symbol-annotation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.5</version>
</dependency>

<!--XStream-->
<dependency>
Expand Down
4 changes: 0 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ THE SOFTWARE.
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/hudson/model/BuildAuthorizationToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import hudson.security.ACL;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import jenkins.model.Jenkins;
import jenkins.security.ApiTokenProperty;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.StaplerRequest;
Expand Down Expand Up @@ -68,9 +67,6 @@ public static BuildAuthorizationToken create(StaplerRequest req) {
}

public static void checkPermission(Job<?, ?> project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException {
if (!Jenkins.get().isUseSecurity())
return; // everyone is authorized

if (token != null && token.token != null) {
//check the provided token
String providedToken = req.getParameter("token");
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/java/hudson/model/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Util;
import hudson.model.labels.LabelAtom;
Expand Down Expand Up @@ -134,6 +135,7 @@ protected boolean matches(Queue.Item item, SubTask subTask) {
/**
* Alias for {@link #getDisplayName()}.
*/
@NonNull
@Exported(visibility = 2)
public final String getName() {
return getDisplayName();
Expand Down Expand Up @@ -584,7 +586,8 @@ public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingCont
* so that the caller can add more to the set.
* @since 1.308
*/
public static Set<LabelAtom> parse(String labels) {
@NonNull
public static Set<LabelAtom> parse(@CheckForNull String labels) {
final Set<LabelAtom> r = new TreeSet<>();
labels = fixNull(labels);
if (labels.length() > 0) {
Expand All @@ -598,6 +601,7 @@ public static Set<LabelAtom> parse(String labels) {
/**
* Obtains a label by its {@linkplain #getName() name}.
*/
@CheckForNull
public static Label get(String l) {
return Jenkins.get().getLabel(l);
}
Expand All @@ -607,7 +611,7 @@ public static Label get(String l) {
*
* TODO: replace this with a real parser later
*/
public static Label parseExpression(String labelExpression) throws ANTLRException {
public static Label parseExpression(@NonNull String labelExpression) throws ANTLRException {
LabelExpressionLexer lexer = new LabelExpressionLexer(new StringReader(labelExpression));
return new LabelExpressionParser(lexer).expr();
}
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/hudson/model/UpdateSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static jenkins.util.MemoryReductionUtil.EMPTY_STRING_ARRAY;
import static jenkins.util.MemoryReductionUtil.getPresizedMutableMap;
import static jenkins.util.MemoryReductionUtil.internInPlace;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
Expand Down Expand Up @@ -80,6 +78,7 @@
import jenkins.security.UpdateSiteWarningsConfiguration;
import jenkins.security.UpdateSiteWarningsMonitor;
import jenkins.util.JSONSignatureValidator;
import jenkins.util.PluginLabelUtil;
import jenkins.util.SystemProperties;
import jenkins.util.java.JavaUtils;
import net.sf.json.JSONArray;
Expand Down Expand Up @@ -1238,7 +1237,7 @@ public Plugin(String sourceId, JSONObject o) {
}
this.popularity = popularity;
this.releaseTimestamp = date;
this.categories = o.has("labels") ? internInPlace((String[]) o.getJSONArray("labels").toArray(EMPTY_STRING_ARRAY)) : null;
this.categories = o.has("labels") ? PluginLabelUtil.canonicalLabels(o.getJSONArray("labels")) : null;
this.issueTrackers = o.has("issueTrackers") ? o.getJSONArray("issueTrackers").stream().map(IssueTracker::createFromJSONObject).filter(Objects::nonNull).toArray(IssueTracker[]::new) : null;

JSONArray ja = o.getJSONArray("dependencies");
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/hudson/model/labels/LabelAtom.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.BulkChange;
import hudson.CopyOnWrite;
Expand Down Expand Up @@ -87,7 +88,7 @@ public class LabelAtom extends Label implements Saveable {

private String description;

public LabelAtom(String name) {
public LabelAtom(@NonNull String name) {
super(name);
}

Expand All @@ -111,6 +112,7 @@ public String getExpression() {
* should do so by implementing {@link LabelAtomProperty#getActions(LabelAtom)}.
*/
@SuppressWarnings("deprecation")
@NonNull
@Override
public List<Action> getActions() {
// add all the transient actions, too
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/hudson/model/labels/LabelExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import hudson.util.FormValidation;
import hudson.util.VariableResolver;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import jenkins.model.Jenkins;
Expand Down Expand Up @@ -286,14 +287,15 @@ public static FormValidation validate(@Nullable String expression, @CheckForNull
}
final Jenkins j = Jenkins.get();
Label l = j.getLabel(expression);
if (l.isEmpty()) {
if (l == null || l.isEmpty()) {
final LabelAtom masterLabel = LabelAtom.get("master");
if (!masterLabel.equals(Jenkins.get().getSelfLabel()) && l.listAtoms().contains(masterLabel) && masterLabel.isEmpty()) {
final Set<LabelAtom> labelAtoms = (l == null ? Collections.emptySet() : l.listAtoms());
if (!masterLabel.equals(Jenkins.get().getSelfLabel()) && labelAtoms.contains(masterLabel) && masterLabel.isEmpty()) {
// Show a warning if this expression's lack of nodes and clouds is likely caused by the built-in node name migration.
// This can probably be done better (e.g. also when `!l.isEmpty()`), but it's a start.
return FormValidation.warningWithMarkup(Messages.LabelExpression_ObsoleteMasterLabel());
}
for (LabelAtom a : l.listAtoms()) {
for (LabelAtom a : labelAtoms) {
if (a.isEmpty()) {
LabelAtom nearest = LabelAtom.findNearest(a.getName());
return FormValidation.warning(Messages.LabelExpression_NoMatch_DidYouMean(a.getName(), nearest.getDisplayName()));
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/scm/SCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public boolean supportsPolling() {
*
* <p>
* This flag affects the behavior of Hudson when a job lost its workspace
* (typically due to a agent outage.) If this method returns false and
* polling is configured, then that would immediately trigger a new build.
* (typically due to a agent outage.) If this method returns true and
* polling is configured, then that would usually trigger a new build.
*
* <p>
* This flag also affects the mutual exclusion control between builds and polling.
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/jenkins/model/Jenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,7 @@ public Computer[] getComputers() {
* @return null if name is null.
* @see Label#parseExpression(String) (String)
*/
@CheckForNull
public Label getLabel(String expr) {
if (expr == null) return null;
expr = QuotedStringTokenizer.unquote(expr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static boolean isDetachedPlugin(@NonNull String pluginId) {
return false;
}

private static Stream<String> configLines(InputStream is) throws IOException {
public static Stream<String> configLines(InputStream is) throws IOException {
return IOUtils.readLines(is, StandardCharsets.UTF_8).stream().filter(line -> !line.matches("#.*|\\s*"));
}

Expand Down
68 changes: 68 additions & 0 deletions core/src/main/java/jenkins/util/PluginLabelUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* The MIT License
*
* Copyright (c) 2022 Jenkins contributors
*
* 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 jenkins.util;

import static jenkins.util.MemoryReductionUtil.EMPTY_STRING_ARRAY;

import hudson.Util;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import jenkins.plugins.DetachedPluginsUtil;
import net.sf.json.JSONArray;

public class PluginLabelUtil {
private static HashMap<String, String> renamedLabels;

private static String canonicalLabel(String label) {
if (renamedLabels == null) {
renamedLabels = new HashMap<>();
try (InputStream is = PluginLabelUtil.class.getResourceAsStream("/jenkins/canonical-labels.txt")) {
DetachedPluginsUtil.configLines(is).forEach(line -> {
String[] pieces = line.split(" ");
renamedLabels.put(pieces[0], pieces[1]);
});
} catch (IOException x) {
throw new ExceptionInInitializerError(x);
}
}
return renamedLabels.getOrDefault(label, label);
}

/**
* Replaces labels with their canonical form and removes duplicates
* @param labels labels array
* @return unique canonical labels
*/
public static String[] canonicalLabels(JSONArray labels) {
HashSet<String> uniqueLabels = new HashSet<>();
for (Object label : labels) {
uniqueLabels.add(Util.intern(canonicalLabel(label.toString())));
}
return uniqueLabels.toArray(EMPTY_STRING_ARRAY);
}

}
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ UpdateCenter.PluginCategory.dotnet=.NET Development
UpdateCenter.PluginCategory.external=External Site/Tool Integrations
UpdateCenter.PluginCategory.groovy-related=Groovy-related
UpdateCenter.PluginCategory.ios=iOS Development
UpdateCenter.PluginCategory.library=Library plugins (for use by other plugins)
UpdateCenter.PluginCategory.api-plugin=Library plugins (for use by other plugins)
UpdateCenter.PluginCategory.listview-column=List view columns
UpdateCenter.PluginCategory.maven=Maven
UpdateCenter.PluginCategory.misc=Miscellaneous
Expand All @@ -326,7 +326,7 @@ UpdateCenter.PluginCategory.scala=Scala Development
UpdateCenter.PluginCategory.scm=Source Code Management
UpdateCenter.PluginCategory.scm-related=Source Code Management related
UpdateCenter.PluginCategory.security=Security
UpdateCenter.PluginCategory.slaves=Agent Management
UpdateCenter.PluginCategory.agent=Agent Management
UpdateCenter.PluginCategory.test=Testing
UpdateCenter.PluginCategory.theme=UI Themes
UpdateCenter.PluginCategory.trigger=Build Triggers
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_bg.properties
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ UpdateCenter.PluginCategory.groovy-related=\
\u0421\u0432\u044a\u0440\u0437\u0430\u043d\u0438 \u0441 Groovy
UpdateCenter.PluginCategory.ios=\
\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u0438\u0440\u0430\u043d\u0435 \u0437\u0430 iOS
UpdateCenter.PluginCategory.library=\
UpdateCenter.PluginCategory.api-plugin=\
\u041f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0438-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 (\u0438\u0437\u043f\u043e\u043b\u0437\u0432\u0430\u0442 \u0441\u0435 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438 \u043f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0438)
UpdateCenter.PluginCategory.listview-column=\
\u041a\u043e\u043b\u043e\u043d\u0438 \u0432 \u0441\u043f\u0438\u0441\u044a\u0447\u043d\u0438\u044f \u0438\u0437\u0433\u043b\u0435\u0434
Expand Down Expand Up @@ -637,7 +637,7 @@ ComputerSet.SpecifySlaveToCopy=\
Slave.WindowsSlave=\
\u0422\u043e\u0432\u0430 \u0435 \u0430\u0433\u0435\u043d\u0442 \u0437\u0430 Windows
# Agent Launchers and Controllers
UpdateCenter.PluginCategory.slaves=\
UpdateCenter.PluginCategory.agent=\
\u0421\u0442\u0430\u0440\u0442\u0438\u0440\u0430\u043d\u0435 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u0430\u0433\u0435\u043d\u0442\u0438
MultiStageTimeSeries.EMPTY_STRING=\
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ UpdateCenter.PluginCategory.dotnet=.NET-Entwicklung
UpdateCenter.PluginCategory.external=Integration externer Sites und Werkzeuge
UpdateCenter.PluginCategory.groovy-related=Groovy (weiteres Umfeld)
UpdateCenter.PluginCategory.ios=iOS-Entwicklung
UpdateCenter.PluginCategory.library=Programmbibliotheken (von anderen Plugins verwendet)
UpdateCenter.PluginCategory.api-plugin=Programmbibliotheken (von anderen Plugins verwendet)
UpdateCenter.PluginCategory.listview-column=Spalten f\u00FCr Listenansichten
UpdateCenter.PluginCategory.maven=Maven bzw. Plugins mit besonderer Maven-Unterst\u00FCtzung
UpdateCenter.PluginCategory.misc=Verschiedenes
Expand All @@ -326,7 +326,7 @@ UpdateCenter.PluginCategory.scala=Scala-Entwicklung
UpdateCenter.PluginCategory.scm=Versionsverwaltung
UpdateCenter.PluginCategory.scm-related=Versionsverwaltung (weiteres Umfeld)
UpdateCenter.PluginCategory.security=Sicherheit
UpdateCenter.PluginCategory.slaves=Agenten-Start und -Steuerung
UpdateCenter.PluginCategory.agent=Agenten-Start und -Steuerung
UpdateCenter.PluginCategory.test=Testen
UpdateCenter.PluginCategory.trigger=Build-Ausl\u00F6ser
UpdateCenter.PluginCategory.ui=Benutzeroberfl\u00E4che
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ UpdateCenter.PluginCategory.post-build=Plugins que a\u00f1aden acciones de post-
UpdateCenter.PluginCategory.report=Plugins para generar informes
UpdateCenter.PluginCategory.scm=Plugins de repositorios de software
UpdateCenter.PluginCategory.scm-related=Plugins relacionados con la gesti\u00f3n repositorios
UpdateCenter.PluginCategory.slaves=Plugins para el control de nodos
UpdateCenter.PluginCategory.agent=Plugins para el control de nodos


UpdateCenter.PluginCategory.trigger=Plugins lanzadores de tareas
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ UpdateCenter.PluginCategory.dotnet=Sviluppo .NET
UpdateCenter.PluginCategory.external=Integrazioni siti/strumenti esterni
UpdateCenter.PluginCategory.groovy-related=Componenti legati a Groovy
UpdateCenter.PluginCategory.ios=Sviluppo iOS
UpdateCenter.PluginCategory.library=Componenti libreria (per l''utilizzo da \
UpdateCenter.PluginCategory.api-plugin=Componenti libreria (per l''utilizzo da \
parte di altri componenti aggiuntivi)
UpdateCenter.PluginCategory.listview-column=Colonne visualizzazione elenco
UpdateCenter.PluginCategory.maven=Maven
Expand All @@ -423,7 +423,7 @@ UpdateCenter.PluginCategory.scm=Gestione del codice sorgente
UpdateCenter.PluginCategory.scm-related=Componenti legati alla gestione del \
codice sorgente
UpdateCenter.PluginCategory.security=Sicurezza
UpdateCenter.PluginCategory.slaves=Avvio e controllo agenti
UpdateCenter.PluginCategory.agent=Avvio e controllo agenti
UpdateCenter.PluginCategory.test=Test
UpdateCenter.PluginCategory.theme=Temi interfaccia utente
UpdateCenter.PluginCategory.trigger=Trigger compilazione
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/hudson/model/Messages_lt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ UpdateCenter.PluginCategory.dotnet=.NET k\u016brimas
UpdateCenter.PluginCategory.external=I\u0161orin\u0117 svetain\u0117/\u012franki\u0173 integracija
UpdateCenter.PluginCategory.groovy-related=Groovy-susij\u0119s
UpdateCenter.PluginCategory.ios=iOS k\u016brimas
UpdateCenter.PluginCategory.library=Bibliotek\u0173 priedai (naudojami kit\u0173 pried\u0173)
UpdateCenter.PluginCategory.api-plugin=Bibliotek\u0173 priedai (naudojami kit\u0173 pried\u0173)
UpdateCenter.PluginCategory.listview-column=Rodinio s\u0105ra\u0161o stulpeliai
UpdateCenter.PluginCategory.maven=Maven
UpdateCenter.PluginCategory.misc=\u012evair\u016bs
Expand All @@ -268,7 +268,7 @@ UpdateCenter.PluginCategory.scala=Scala k\u016brimas
UpdateCenter.PluginCategory.scm=I\u0161eities kodo valdymas
UpdateCenter.PluginCategory.scm-related=Susij\u0119 su i\u0161eities kodo valdymu
UpdateCenter.PluginCategory.security=Saugumas
UpdateCenter.PluginCategory.slaves=Agent\u0173 paleid\u0117jai ir valdytojai
UpdateCenter.PluginCategory.agent=Agent\u0173 paleid\u0117jai ir valdytojai
UpdateCenter.PluginCategory.test=Testavimas
UpdateCenter.PluginCategory.trigger=Vykdymo trigeriai
UpdateCenter.PluginCategory.ui=Naudotojo s\u0105saja
Expand Down
Loading

0 comments on commit d0f9acc

Please sign in to comment.