From 196d0b7e21b3291665bed34d90e0f85d452d1577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= <91831478+lemeurherve@users.noreply.github.com> Date: Mon, 12 Feb 2024 00:10:30 +0100 Subject: [PATCH] feat: add plugin manager input syntax to check run summary (#88) * feat: add plugin manager input syntax to check run * render download links and plugin manager input format entries as a table instead of two lists * Reduce first header lenght * there can be only one link * retrieve all info from pom (groupId, version, packaging) * use info returned from pom, and show input format only for hpi * better header for plugin manager column * remove table * titles and summary formating * use fenced code block to get copy button * pluralise Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com> * add new line after link title * lint, strings must use doublequote --------- Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com> --- IncrementalsPlugin.js | 7 ++++--- lib/github.js | 4 +++- lib/permissions.js | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/IncrementalsPlugin.js b/IncrementalsPlugin.js index 51dfae3..63ba37b 100644 --- a/IncrementalsPlugin.js +++ b/IncrementalsPlugin.js @@ -240,9 +240,10 @@ class IncrementalsPlugin { const entriesForDisplay = entries.map(entry => { return { artifactId: entry.artifactId, - url: config.INCREMENTAL_URL + entry.path.replace(/[^/]+$/, ""), - version: entry.path.split("/").slice(-2)[0], - groupId: entry.path.split("/").slice(0, 3).join(".") + groupId: entry.groupId, + version: entry.version, + hpi: (entry.packaging == "hpi" ? `${entry.artifactId}:incrementals;${entry.groupId};${entry.version} ` : ""), + url: config.INCREMENTAL_URL + entry.path.replace(/[^/]+$/, "") }; }) diff --git a/lib/github.js b/lib/github.js index 7a48fe3..7e093f2 100644 --- a/lib/github.js +++ b/lib/github.js @@ -39,6 +39,8 @@ export default { createStatus: async (owner, repo, head_sha, entries) => { const github = await getRestClient(); + const links = `### Download link${entries.length > 1 ? "s" : ""}:` + "\n" + entries.map(entry => `- [${entry.artifactId}](${entry.url})`).join("\n") + const inputFormat = "### Plugin Installation Manager input format:\n```" + entries.map(entry => entry.hpi).join("") + "```\n([documentation](https://github.com/jenkinsci/plugin-installation-manager-tool/#plugin-input-format))" const metadata = entries.map(entry => `<dependency> <groupId>${entry.groupId}</groupId> <artifactId>${entry.artifactId}</artifactId> <version>${entry.version}</version> </dependency>`).join(" ") return github.rest.checks.create({ @@ -51,7 +53,7 @@ export default { details_url: entries[0].url, output: { title: `Deployed version ${entries[0].version} to Incrementals`, - summary: entries.map(entry => `- [${entry.artifactId}](${entry.url})`).join("\n"), + summary: links + inputFormat, text: `
${metadata}` } }); diff --git a/lib/permissions.js b/lib/permissions.js index 4b90b72..7003dfe 100644 --- a/lib/permissions.js +++ b/lib/permissions.js @@ -57,8 +57,12 @@ export default { const groupId = result.project.groupId[0]; const artifactId = result.project.artifactId[0]; const version = result.project.version[0]; + const packaging = result.project.packaging ? result.project.packaging[0] : "" entries.push({ artifactId, + groupId, + version, + packaging, path: entry.name }); log.info(util.format("Parsed %s with url=%s tag=%s GAV=%s:%s:%s", entry.name, url, tag, groupId, artifactId, version));