Skip to content
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

Add copy-to-clipboard button to the build console output #8960

Merged
merged 6 commits into from
Mar 5, 2024

Conversation

anhcraft
Copy link
Contributor

@anhcraft anhcraft commented Feb 14, 2024

  • The build's output currently lacks a copy-to-clipboard button. This is a small QoL improvement to quickly copy the console output. The button also supports progressive text output.
  • The copy button only supports text via the attribute text. Therefore, this PR also introduces another parameter ref to refer to the target element using the id. Compared to the text approach, it has some advantages: reduces page size, supports formatted logging output and can work across UI components.

Testing done

Manually testing

Before:
https://i.imgur.com/xSRIkKQ.png

After:
https://i.imgur.com/Mia5Ie3.png

Proposed changelog entries

  • Add "copy to clipboard" button to the build console output.

Submitter checklist

Tasks

Desired reviewers

@jenkinsci/core-pr-reviewers

Before the changes are marked as ready-for-merge:

Maintainer checklist

Tasks

Copy link

welcome bot commented Feb 14, 2024

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

@NotMyFault NotMyFault added rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted needs-security-review Awaiting review by a security team member labels Feb 14, 2024
@NotMyFault NotMyFault requested a review from a team February 14, 2024 22:03
@MarkEWaite
Copy link
Contributor

Thanks for the pull request @anhcraft . When you performed the testing, did you confirm that the copied text was inserted into the clipboard? When I've tested these types of pull requests in the past, I needed to use an HTTPS URL to check that the correct text was placed on the clipboard.

@timja
Copy link
Member

timja commented Feb 15, 2024

I needed to use an HTTPS URL to check that the correct text was placed on the clipboard.

It should be a secure context, which is localhost or https url

@anhcraft
Copy link
Contributor Author

Thanks for the pull request @anhcraft . When you performed the testing, did you confirm that the copied text was inserted into the clipboard? When I've tested these types of pull requests in the past, I needed to use an HTTPS URL to check that the correct text was placed on the clipboard.

It worked for me when running locally. My PR does not change the secure-context check at all.
Related PRs: #7665 #8554

@anhcraft
Copy link
Contributor Author

Confirmed it works for existing copy buttons (script console, agent page )

Screenshot 2024-02-16 011213

@lemeurherve
Copy link
Member

lemeurherve commented Feb 15, 2024

Would it be possible to put the copy button in the top right corner of the logs like it's done on GitHub amongst others?

Having it alongside titles gives the false impression that's their content which will be copied, it's not obvious at first look these buttons concern the logs block below.

Exemple of a block with a copy button on the top right corner.


Another line.


The end.

@MarkEWaite
Copy link
Contributor

Would it be possible to put the copy button in the top right corner of the logs like it's done on GitHub amongst others?

I think that is a reasonable request for another pull request, since the placement that @anhcraft has selected is consistent with the placement of other copy buttons in Jenkins.

@yaroslavafenkin yaroslavafenkin added security-approved @jenkinsci/core-security-review reviewed this PR for security issues and removed needs-security-review Awaiting review by a security team member labels Feb 16, 2024
@anhcraft anhcraft requested a review from NotMyFault February 18, 2024 04:42
Copy link
Member

@NotMyFault NotMyFault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@NotMyFault NotMyFault requested a review from a team February 18, 2024 15:50
@NotMyFault NotMyFault requested a review from a team February 20, 2024 14:21
@NotMyFault NotMyFault requested a review from timja March 4, 2024 14:47
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/label ready-for-merge


This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Mar 4, 2024
@NotMyFault NotMyFault merged commit b0a251a into jenkinsci:master Mar 5, 2024
17 checks passed
Copy link

welcome bot commented Mar 5, 2024

Congratulations on getting your very first Jenkins core pull request merged 🎉🥳

This is a fantastic achievement, and we're thrilled to have you as part of our community! Thank you for your valuable input, and we look forward to seeing more of your contributions in the future!

We would like to invite you to join the community chats and forums to meet other Jenkins contributors 😊
Don't forget to check out the participation page to learn more about how to contribute to Jenkins.


@reinholdfuereder
Copy link
Contributor

reinholdfuereder commented Jul 17, 2024

Sorry for commenting on this long ago resolved ticket:

  • But where should this "Copy" button be visible?

(Note: I am using Jenkins v2.452.3 and look in classic UI at the "Console Output" view of a recently ran pipeline)

Oh! There is a problem with my LDAP configuration -- after Jenkins upgrade from 2.426.3 => 2.452.3 -- I need to look into that problem first...

  • No, that was just a temporary local LDAP server problem... Jesus!

So actually: when and where should I see this "Copy" button?

@timja
Copy link
Member

timja commented Jul 17, 2024

Its in the top right of the console log:

image

@reinholdfuereder
Copy link
Contributor

Thanks for your fast response Tim.
BUT: I am really sorry, but either I am blind, or I am looking at the completely wrong view?
Screenshot 2024-07-18 at 07 50 52

@timja
Copy link
Member

timja commented Jul 18, 2024

not sure, maybe a plugin is out of date?

@reinholdfuereder
Copy link
Contributor

Well, no, not really: Only Blue Ocean 1.27.14 was just released and I have "just" 1.27.13 installed.

Is the view from my screenshot above the right one? That is, should it be there? (Or am I on the wrong track or view?)

@timja
Copy link
Member

timja commented Jul 18, 2024

Should be, I'm not sure why its not there for you

@reinholdfuereder
Copy link
Contributor

Oh, maybe this comment explains it: #9169 (comment)

Because I was "only" looking at the "Console output" of a scripted pipeline job so far...
(We do not have any freestyle jobs at all)

@timja
Copy link
Member

timja commented Jul 18, 2024

Which was ported to pipeline in jenkinsci/workflow-job-plugin#439

I tested with a pipeline

@reinholdfuereder
Copy link
Contributor

Well, no, not really: Only Blue Ocean 1.27.14 was just released and I have "just" 1.27.13 installed. And besides that now "Configuration as Code" (1810 => 1836) and GitHub Branch Source (1789 => 1790) and Pipeline API (1316 => 1322).

Oh, the version of aforementioned "workflow-job" plugin installed is only 1400.v7fd111b_ec82f (released already ~6 months ago) -- and for my version of Jenkins core (2.425.3) there is (according to the Jenkins plugin manager Web UI) no update available of this plugin. Although there are/were newer releases of this plugin, like e.g. 1436.vfa_244484591f (2 weeks ago) with the aforementioned fix for pipeline (jenkinsci/workflow-job-plugin#439).

That explains the missing feature. Thanks!

However, I am wondering why I don't get this update. When I specify this latest version of the plugin in the corresponding Job DSL tests I actually get this (matching) error message:

0.864 [id=65]	SEVERE	jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Pipeline: Job v1436.vfa_244484591f (workflow-job)
java.io.IOException: Failed to load: Pipeline: Job (workflow-job 1436.vfa_244484591f)
 - Jenkins (2.454) or higher required
	at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:992)
	at hudson.PluginManager$2$1$1.run(PluginManager.java:552)
	at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:177)
	at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:305)
	at jenkins.model.Jenkins$5.runTask(Jenkins.java:1175)
	at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:221)
	at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:120)
	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

And in https://github.com/jenkinsci/workflow-job-plugin/blob/master/pom.xml I see something that may be related?

<jenkins.version>2.454</jenkins.version>

So that explains everything?

@timja
Copy link
Member

timja commented Jul 22, 2024

Yup exactly so it'll be available in the next LTS version which will be released on 7th August

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted security-approved @jenkinsci/core-security-review reviewed this PR for security issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants