diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 4d1cb7e8c..be08f5703 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -43,7 +43,7 @@ jobs: if: needs.validate.outputs.should_release == 'true' steps: - name: Check out - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up JDK 8 diff --git a/pom.xml b/pom.xml index 225c37d6c..516f5f68d 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 999999-SNAPSHOT jenkinsci/${project.artifactId}-plugin - 2.332.1 + 2.340 8 4.9.3 @@ -128,13 +128,13 @@ org.kohsuke.metainf-services metainf-services - 1.8 + 1.9 provided org.xmlunit xmlunit-matchers - 2.8.4 + 2.9.0 test @@ -200,10 +200,10 @@ pdfs - 2.2.1 + 2.2.2 1.6.2 - 2.5.2 - 9.3.2.0 + 2.5.3 + 9.3.4.0 diff --git a/src/main/java/com/cloudbees/plugins/credentials/ContextMenuIconUtils.java b/src/main/java/com/cloudbees/plugins/credentials/ContextMenuIconUtils.java index c8a022837..289fa1af9 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/ContextMenuIconUtils.java +++ b/src/main/java/com/cloudbees/plugins/credentials/ContextMenuIconUtils.java @@ -174,12 +174,6 @@ public static String getMenuItemIconUrl(String url) { */ @CheckForNull public static Icon getIconByClassSpec(String spec) { - try { - Method getIconByClassSpec = IconSet.class.getMethod("getIconByClassSpec", Object.class); - return (Icon) getIconByClassSpec.invoke(IconSet.icons, spec); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - // ignore - } return IconSet.icons.getIconByClassSpec(spec); } @@ -196,35 +190,14 @@ public static Icon getIcon(@NonNull Action action) { if (action.getIconFileName() == null) { return null; } - Icon icon; - try { - Method getIconByClassSpec = IconSet.class.getMethod("getIconByClassSpec", Object.class); - icon = action instanceof IconSpec - ? (Icon) getIconByClassSpec.invoke(IconSet.icons, ((IconSpec) action).getIconClassName()) - : null; - if (icon != null) { - return icon; - } - Method toNormalizedIconNameClass = IconSet.class.getMethod("toNormalizedIconNameClass", Object.class); - icon = (Icon) getIconByClassSpec - .invoke(IconSet.icons, toNormalizedIconNameClass.invoke(null, action.getIconFileName())); - if (icon != null) { - return icon; - } - Method getIconByUrl = IconSet.class.getMethod("getIconByUrl", Object.class); - return (Icon) getIconByUrl.invoke(IconSet.icons, action.getIconFileName()); - } catch (NoSuchMethodException e) { - icon = action instanceof IconSpec - ? IconSet.icons.getIconByClassSpec(((IconSpec) action).getIconClassName()) - : null; - if (icon == null) { - icon = IconSet.icons.getIconByClassSpec(IconSet.toNormalizedIconNameClass(action.getIconFileName())); - } - if (icon == null) { - icon = IconSet.icons.getIconByUrl(action.getIconFileName()); - } - } catch (InvocationTargetException | IllegalAccessException e) { - icon = null; + Icon icon = action instanceof IconSpec + ? IconSet.icons.getIconByClassSpec(((IconSpec) action).getIconClassName()) + : null; + if (icon == null) { + icon = IconSet.icons.getIconByClassSpec(IconSet.toNormalizedIconNameClass(action.getIconFileName())); + } + if (icon == null) { + icon = IconSet.icons.getIconByUrl(action.getIconFileName()); } return icon; } diff --git a/src/main/java/com/cloudbees/plugins/credentials/Credentials.java b/src/main/java/com/cloudbees/plugins/credentials/Credentials.java index f1c5107bd..e556bd035 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/Credentials.java +++ b/src/main/java/com/cloudbees/plugins/credentials/Credentials.java @@ -27,6 +27,7 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionPoint; import hudson.model.Describable; +import hudson.model.Run; import java.io.Serializable; /** @@ -54,4 +55,16 @@ public interface Credentials extends Describable, Serializable, Ext @NonNull @SuppressWarnings("unchecked") CredentialsDescriptor getDescriptor(); + + /** + * Optionally produce a special value when used in the context of a particular build. + * @param context a build wishing to consume these credentials + * @return contextualized credentials, preferably implementing the same interfaces (if not of the same concrete type); by default, {@code this} + * @see CredentialsProvider#findCredentialById(java.lang.String, java.lang.Class, hudson.model.Run, com.cloudbees.plugins.credentials.domains.DomainRequirement...) + */ + @NonNull + default Credentials forRun(@NonNull Run, ?> context) { + return this; + } + } diff --git a/src/main/java/com/cloudbees/plugins/credentials/CredentialsDescriptor.java b/src/main/java/com/cloudbees/plugins/credentials/CredentialsDescriptor.java index c894b3290..0b721f63a 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/CredentialsDescriptor.java +++ b/src/main/java/com/cloudbees/plugins/credentials/CredentialsDescriptor.java @@ -243,7 +243,7 @@ public String getCredentialsPage() { * @since 1.25 */ public String getIconClassName() { - return "icon-credentials-credential"; + return "symbol-key"; } /** diff --git a/src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterValue.java b/src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterValue.java index 68584cefe..ca5a2ab27 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterValue.java +++ b/src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterValue.java @@ -156,7 +156,7 @@ public String iconClassName() { if (c != null) { return c.getDescriptor().getIconClassName(); } - return "icon-credentials-credential"; + return "symbol-key"; } public String url() { diff --git a/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java b/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java index cb8a6db63..8dab91aa9 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java +++ b/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java @@ -916,7 +916,8 @@ public static C findCredentialById(@NonNull String id, CredentialsProvider.lookupCredentials(type, run.getParent(), ACL.SYSTEM, domainRequirements) ); } - return CredentialsMatchers.firstOrNull(candidates, CredentialsMatchers.withId(id)); + // TODO should this be calling track? + return contextualize(type, CredentialsMatchers.firstOrNull(candidates, CredentialsMatchers.withId(id)), run); } // this is a parameter and not the default value, we need to determine who triggered the build final Map.Entry> triggeredBy = triggeredBy(run); @@ -957,7 +958,23 @@ public static C findCredentialById(@NonNull String id, C result = CredentialsMatchers.firstOrNull(candidates, CredentialsMatchers.withId(id)); // if the run has not completed yet then we can safely assume that the credential is being used for this run // so we will track it's usage. We use isLogUpdated() as it could be used during post production - return run.isLogUpdated() ? track(run, result) : result; + if (run.isLogUpdated()) { + track(run, result); + } + return contextualize(type, result, run); + } + + @CheckForNull + private static C contextualize(@NonNull Class type, @CheckForNull C credentials, @NonNull Run, ?> run) { + if (credentials != null) { + Credentials contextualized = credentials.forRun(run); + if (type.isInstance(contextualized)) { + return type.cast(contextualized); + } else { + LOGGER.warning(() -> "Ignoring " + contextualized.getClass().getName() + " return value of " + credentials.getClass().getName() + ".forRun since it is not assignable to " + type.getName()); + } + } + return credentials; } /** @@ -1075,7 +1092,7 @@ public String getDisplayName() { */ @Override public String getIconClassName() { - return "icon-credentials-credentials"; + return "symbol-key"; } /** diff --git a/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java b/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java index e5cd2df79..f511c9284 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java +++ b/src/main/java/com/cloudbees/plugins/credentials/CredentialsStoreAction.java @@ -86,6 +86,7 @@ import net.sf.json.JSONObject; import org.acegisecurity.AccessDeniedException; import org.apache.commons.lang.StringUtils; +import org.jenkins.ui.icon.IconSet; import org.jenkins.ui.icon.IconSpec; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -406,7 +407,7 @@ public boolean isVisible() { @Override public String getIconClassName() { return isVisible() - ? "icon-credentials-credentials" + ? "symbol-key" : null; } diff --git a/src/main/java/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration.java b/src/main/java/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration.java index 8806aa693..88c50044e 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration.java +++ b/src/main/java/com/cloudbees/plugins/credentials/GlobalCredentialsConfiguration.java @@ -78,7 +78,7 @@ public class GlobalCredentialsConfiguration extends ManagementLink public String getIconFileName() { return ExtensionList.lookup(CredentialsDescriptor.class).isEmpty() ? null - : "/plugin/credentials/images/credentials.svg"; + : "symbol-key"; } /** diff --git a/src/main/java/com/cloudbees/plugins/credentials/ManageCredentialsConfiguration.java b/src/main/java/com/cloudbees/plugins/credentials/ManageCredentialsConfiguration.java index 04b87b2b6..e074a5cd8 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/ManageCredentialsConfiguration.java +++ b/src/main/java/com/cloudbees/plugins/credentials/ManageCredentialsConfiguration.java @@ -22,7 +22,7 @@ public String getCategoryName() { @Override public String getIconFileName() { - return "/plugin/credentials/images/credentials.svg"; + return "symbol-key"; } @Override diff --git a/src/main/java/com/cloudbees/plugins/credentials/SystemCredentialsProvider.java b/src/main/java/com/cloudbees/plugins/credentials/SystemCredentialsProvider.java index 9fb61bc1c..481f92ad0 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/SystemCredentialsProvider.java +++ b/src/main/java/com/cloudbees/plugins/credentials/SystemCredentialsProvider.java @@ -472,7 +472,7 @@ public List getCredentials(@NonNull Class type, @N @Override public String getIconClassName() { - return "icon-credentials-system-store"; + return "symbol-jenkins"; } } @@ -629,7 +629,7 @@ public CredentialsStore getStore() { @Override public String getIconFileName() { return isVisible() - ? "/plugin/credentials/images/system-store.svg" + ? "symbol-jenkins" : null; } @@ -639,7 +639,7 @@ public String getIconFileName() { @Override public String getIconClassName() { return isVisible() - ? "icon-credentials-system-store" + ? "symbol-jenkins" : null; } diff --git a/src/main/java/com/cloudbees/plugins/credentials/UserCredentialsProvider.java b/src/main/java/com/cloudbees/plugins/credentials/UserCredentialsProvider.java index 3668e820e..a30105dcc 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/UserCredentialsProvider.java +++ b/src/main/java/com/cloudbees/plugins/credentials/UserCredentialsProvider.java @@ -164,7 +164,7 @@ public List getCredentials(@NonNull Class type, */ @Override public String getIconClassName() { - return "icon-credentials-user-store"; + return "symbol-person"; } /** @@ -569,7 +569,7 @@ public CredentialsStore getStore() { @Override public String getIconFileName() { return isVisible() - ? "/plugin/credentials/images/user-store.svg" + ? "symbol-person" : null; } @@ -579,7 +579,7 @@ public String getIconFileName() { @Override public String getIconClassName() { return isVisible() - ? "icon-credentials-user-store" + ? "symbol-person" : null; } diff --git a/src/main/java/com/cloudbees/plugins/credentials/ViewCredentialsAction.java b/src/main/java/com/cloudbees/plugins/credentials/ViewCredentialsAction.java index 613648808..0b50ddef3 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/ViewCredentialsAction.java +++ b/src/main/java/com/cloudbees/plugins/credentials/ViewCredentialsAction.java @@ -112,7 +112,7 @@ public ModelObject getContext() { @Override public String getIconFileName() { return isVisible() - ? "/plugin/credentials/images/credentials.svg" + ? "symbol-key" : null; } @@ -295,7 +295,7 @@ public List getTableEntries() { @Override public String getIconClassName() { return isVisible() - ? "icon-credentials-credentials" + ? "symbol-key" : null; } diff --git a/src/main/java/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl.java b/src/main/java/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl.java index a50216135..a92d84f48 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl.java +++ b/src/main/java/com/cloudbees/plugins/credentials/impl/CertificateCredentialsImpl.java @@ -216,7 +216,7 @@ public String getDisplayName() { */ @Override public String getIconClassName() { - return "icon-credentials-certificate"; + return "icon-application-certificate"; } } diff --git a/src/main/java/com/cloudbees/plugins/credentials/impl/UsernamePasswordCredentialsImpl.java b/src/main/java/com/cloudbees/plugins/credentials/impl/UsernamePasswordCredentialsImpl.java index bd6ea06b3..bb947482c 100644 --- a/src/main/java/com/cloudbees/plugins/credentials/impl/UsernamePasswordCredentialsImpl.java +++ b/src/main/java/com/cloudbees/plugins/credentials/impl/UsernamePasswordCredentialsImpl.java @@ -126,7 +126,7 @@ public String getDisplayName() { */ @Override public String getIconClassName() { - return "icon-credentials-userpass"; + return "symbol-id-card"; } } } diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly index 9ab14998e..a486f1a9e 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsSelectHelper/WrappedCredentialsStore/dialog.jelly @@ -26,15 +26,10 @@ - - ${it.description}: ${it.displayName} - + ${it.description}: ${it.displayName} - - - ${%Add Credentials} - + ${%Add Credentials} @@ -49,7 +44,7 @@ - diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly index c386cbc49..b2e258977 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/delete.jelly @@ -1,11 +1,14 @@ - + + ${%Delete credentials} - ${%confirm(it.displayName,it.typeName)} - + ${%confirm(it.displayName,it.typeName)} + + + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly index 8b5795586..692da3a1e 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/index.jelly @@ -31,9 +31,7 @@ - ${it.displayName} + ${it.displayName} diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly index c8bf5e316..d4898446d 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/move.jelly @@ -1,29 +1,29 @@ - + - ${%Move} + ${%Move credentials} - ${%blurb(it.displayName,it.typeName)} - - - - - - - ${app.displayName} » ${destination.fullDisplayName} - - - - - ${app.displayName} » ${destination.fullDisplayName} - - - - - - + ${%blurb(it.displayName,it.typeName)} + + + + + + + ${app.displayName} » ${destination.fullDisplayName} + + + + + ${app.displayName} » ${destination.fullDisplayName} + + + + + + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly index dc2ba561e..968c00207 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/sidepanel.jelly @@ -30,7 +30,7 @@ - + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly index 1c3d6b662..b75f51ef0 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/CredentialsWrapper/update.jelly @@ -29,9 +29,10 @@ - + + ${%Update credentials} diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly index a7f69c715..d9802f98a 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/configure.jelly @@ -29,9 +29,10 @@ - + + ${%Update domain} @@ -54,7 +55,7 @@ items="${instance.specifications}"/> - + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly index a0f366034..1ce2cf46d 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/delete.jelly @@ -1,8 +1,9 @@ - + + ${%Delete domain} ${%The global domain cannot be deleted} @@ -12,8 +13,10 @@ - ${%Are you sure about deleting this domain and all credentials in this domain?} - + ${%Are you sure about deleting this domain and all credentials in this domain?} + + + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly index b4e18fd95..7bc784e9a 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/index.jelly @@ -27,84 +27,74 @@ xmlns:f="/lib/form" xmlns:c="/lib/credentials" xmlns:t="/lib/hudson"> + - ${it.displayName} - - - - - - - ${%ID} - - - ${%Name} - - - ${%Kind} - - - ${%Description} - - - - - - + + + + + ${%ID} + ${%Name} + ${%Kind} + ${%Description} + + + + + - - - - - - - ${%noCredentialsAddSome} - - - ${%noCredentials} - - - - - - - - + + - - - - - - - ${c.id} - - - ${c.displayName} - - - ${c.typeName} - - - ${safeDescription} - - - - - - - - + + + + ${%noCredentialsAddSome} + + + ${%noCredentials} + + + - - - - + + + + + + + + + + ${c.id} + + + ${c.displayName} + + + ${c.typeName} + + + ${safeDescription} + + + + + + + + + + + + + diff --git a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/newCredentials.jelly b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/newCredentials.jelly index 4b922e497..534c03640 100644 --- a/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/newCredentials.jelly +++ b/src/main/resources/com/cloudbees/plugins/credentials/CredentialsStoreAction/DomainWrapper/newCredentials.jelly @@ -25,9 +25,10 @@ --> - + + ${%New credentials} @@ -63,13 +64,13 @@ - + - +
${%confirm(it.displayName,it.typeName)}
${%blurb(it.displayName,it.typeName)}
${%Are you sure about deleting this domain and all credentials in this domain?}