Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.version>2.319.1</jenkins.version>
<jenkins.version>2.332.1</jenkins.version>
<java.level>8</java.level>
<antlr4.version>4.9.3</antlr4.version>
</properties>
Expand All @@ -89,7 +89,7 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.319.x</artifactId>
<artifactId>bom-2.332.x</artifactId>
<version>1210.vcd41f6657f03</version>
<scope>import</scope>
<type>pom</type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,9 @@ public static <C extends Credentials> List<C> trackAll(@NonNull Run build, @NonN
} else {
LOGGER.log(Level.FINEST, "TrackAll method (Run variant) called but fingerprints disabled by {0}", FINGERPRINT_ENABLED_NAME);
}
for (Credentials c : credentials) {
CredentialsUseListener.fireUse(c, build);
}
return credentials;
}

Expand Down Expand Up @@ -1561,6 +1564,9 @@ public static <C extends Credentials> List<C> trackAll(@NonNull Node node, @NonN
} else {
LOGGER.log(Level.FINEST, "TrackAll method (Node variant) called but fingerprints disabled by {0}", FINGERPRINT_ENABLED_NAME);
}
for (Credentials c : credentials) {
CredentialsUseListener.fireUse(c, node);
}
return credentials;
}

Expand Down Expand Up @@ -1646,6 +1652,9 @@ public static <C extends Credentials> List<C> trackAll(@NonNull Item item, @NonN
} else {
LOGGER.log(Level.FINEST, "TrackAll method (Item variant) called but fingerprints disabled by {0}", FINGERPRINT_ENABLED_NAME);
}
for (Credentials c : credentials) {
CredentialsUseListener.fireUse(c, item);
}
return credentials;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.cloudbees.plugins.credentials;

import hudson.ExtensionPoint;
import hudson.model.ModelObject;
import jenkins.util.Listeners;


/**
* A Listener to track {@link Credentials } usage.
*/
public abstract class CredentialsUseListener implements ExtensionPoint {

/**
* Called when {@link Credentials} is read by an object.
*
* @param c The used Credentials.
* @param obj The object using the credentials.
*/
public abstract void onUse(Credentials c, ModelObject obj);

/**
* Fires the {@link #onUse} event to track the object that uses credentials.
*/
public static void fireUse(Credentials c, ModelObject obj) {
Listeners.notify(CredentialsUseListener.class, true, listener -> {
listener.onUse(c, obj);
});
}
}