-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[JENKINS-41516] Add script console listener #6539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
meiswjn
wants to merge
25
commits into
jenkinsci:master
from
meiswjn:feature/add-script-console-listener
Closed
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e745089
Set location for listener
meiswjn 060fe1e
Add ScriptListener
meiswjn 89ac091
Remove debugging statements
meiswjn 2aed668
Merge branch 'master' into feature/add-script-console-listener
meiswjn 8d41ad1
Add listener for CLI
meiswjn 5160902
Merge branch 'master' into feature/add-script-console-listener
meiswjn 6b86d43
Merge branch 'jenkinsci:master' into feature/add-script-console-listener
meiswjn dc7728f
Add new listener for other sources
meiswjn c533407
Simplify listener
meiswjn 8e9e618
Merge branch 'master' into feature/add-script-console-listener
meiswjn 02ffdd1
Fix whitespace and comments
meiswjn 0ceef7c
Merge branch 'feature/add-script-console-listener' of https://github.…
meiswjn d30108d
Merge branch 'master' into feature/add-script-console-listener
daniel-beck a2ede02
Merge branch 'master' into feature/add-script-console-listener
daniel-beck 70b1334
Update core/src/main/java/hudson/cli/GroovyCommand.java
meiswjn eadd842
Add precise origins; Correctly log CLI input
meiswjn cc4ce09
Merge branch 'jenkinsci:master' into feature/add-script-console-listener
meiswjn a4a541c
Merge branch 'feature/add-script-console-listener' of https://github.…
meiswjn 301dea2
Add LoggingGroovySh as suggested by @daniel-beck
meiswjn f1e5b03
Add ScriptListener Tests
meiswjn fcf5506
Merge branch 'master' into feature/add-script-console-listener
meiswjn df5b49c
Merge branch 'master' into feature/add-script-console-listener
basil 567e03b
Add basic default listener that just logs
daniel-beck 0526568
Merge branch 'master' into feature/add-script-console-listener
meiswjn 19e7c04
Merge branch 'master' into feature/add-script-console-listener
meiswjn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,38 @@ | ||
| package jenkins.model; | ||
|
|
||
| import hudson.ExtensionPoint; | ||
| import hudson.model.User; | ||
| import jenkins.util.Listeners; | ||
| import org.kohsuke.stapler.StaplerRequest; | ||
|
|
||
| /** | ||
| * A listener to track Groovy scripts. | ||
| * | ||
| * @see Jenkins#_doScript(StaplerRequest, org.kohsuke.stapler.StaplerResponse, javax.servlet.RequestDispatcher, hudson.remoting.VirtualChannel, hudson.security.ACL) | ||
| * @see hudson.cli.GroovyCommand#run() | ||
| * @see hudson.cli.GroovyshCommand#run() | ||
| */ | ||
| public interface ScriptListener extends ExtensionPoint { | ||
|
|
||
| /** | ||
| * Called when a (privileged) groovy script is executed. | ||
| * | ||
| * @see Jenkins#_doScript(StaplerRequest, org.kohsuke.stapler.StaplerResponse, javax.servlet.RequestDispatcher, hudson.remoting.VirtualChannel, hudson.security.ACL) | ||
| * @param script The script to be executed. | ||
| * @param origin Descriptive identifier of the origin where the script is executed (Controller, Agent ID, Run ID). | ||
| * @param u If available, the user that executed the script. Can be null. | ||
| */ | ||
| void onScript(String script, String origin, User u); | ||
|
|
||
| /** | ||
| * Fires the {@link #onScript(String, String, User)} event to track the usage of the script console. | ||
| * | ||
| * @see Jenkins#_doScript(StaplerRequest, org.kohsuke.stapler.StaplerResponse, javax.servlet.RequestDispatcher, hudson.remoting.VirtualChannel, hudson.security.ACL) | ||
| * @param script The script to be executed. | ||
| * @param origin Descriptive identifier of the origin where the script is executed (Controller, Agent ID, Run ID). | ||
| * @param u If available, the user that executed the script. | ||
| */ | ||
| static void fireScriptEvent(String script, String origin, User u) { | ||
| Listeners.notify(ScriptListener.class, true, listener -> listener.onScript(script, origin, u)); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.