How to add something to description but not to the build history?

55 views
Skip to first unread message

Maciej Jaros

unread,
Nov 18, 2024, 9:32:39 AM11/18/24
to jenkins...@googlegroups.com
Hi,
Is there a way to add something to the description or to a build page in general, but not to the build history?

So far, I came up with adding some spacers, but they make the build history taller (add blank vertical space).
I specifically want to use Groovy because I already have a script in Groovy that builds the log.

I'm using this in Groovy:
```
import hudson.FilePath
def appendFileToBuildPage(build, filePath, title) {
    // FilePath = compatible with running on remote nodes
	def logFile = new FilePath(build.workspace, filePath)
	def newContent = ""

	// Check file and add its content on the build page
	if (logFile.exists()) {
		// spacers (should *not* show h2 in build history)
        newContent += "\n<p>(${title.toLowerCase()} available on the build page)</p>"
        newContent += "<p>&nbsp;</p>"
		newContent += "<p>&nbsp;</p>"
		newContent += "<p>&nbsp;</p>"
		// actual content
		newContent += "\n<h2>${title}</h2>\n<pre>${logFile.readToString()}</pre>"
		newContent += "\n<hr>"
	} else {
		newContent += "<p>(the ${title.toLowerCase()} file is missing: ${filePath})</p>"
	}

	// Append content to the description
	def existingDescription = build.getDescription() ?: ""
	build.setDescription(existingDescription + newContent)
}
// append short info
appendFileToBuildPage(build, "logs/short.log.wiki", "Short log")
```

Cheers / Regards,
Maciej

Mark Waite

unread,
Nov 18, 2024, 9:56:44 AM11/18/24
to Jenkins Users
The badge plugin includes a createSummary Pipeline step that will add an icon and text to the build page without adding anything to the list of builds that is displayed on the left in the build history.

The Groovy postbuild plugin also provides a createSummary step.

Mark Waite

Maciej Jaros

unread,
Nov 18, 2024, 11:41:53 AM11/18/24
to jenkins...@googlegroups.com
I've managed to do this without plugins ;)
https://x.com/eccenux/status/1858550202107346986

Would be nice to have and ability to add classes to elements probably.

Mark Waite (2024-11-18 15:56):
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jenkinsci-users/0fcda178-abe2-46df-95b9-0eab8488cae3n%40googlegroups.com.

Christopher Dean

unread,
Nov 27, 2024, 8:20:57 PM11/27/24
to Jenkins Users
WELDING MACHINES AND ACCESSORIES FOR SALE ONLINE WITH SAFE AND GUARANTEED SHIPPING.


SHOP BELOW

Buy discounted welders, plasma cutters and welding safety gear by premium brands like Miller, Lincoln Electric, Hypertherm, Hobart and Black Stallion - from the mouse with over 86 years of welding experience.

where to order welding machines and accessories online with safe shipping.

we have the best welding tools like reels,miller remote,pipe bender,welding cable, lincoln rods,leads,miller welding helmet,mig guns,tig torches,plasma torches,welding cables,mig welders,tig welders,Etc.

Order now from our website below with safe and guaranteed shipping

Reply all
Reply to author
Forward
0 new messages