Skip to content

Commit

Permalink
chore: input format in check summary only if there a plugin (#95)
Browse files Browse the repository at this point in the history
* chore: input format in check summary only if there a plugin

* add comment
  • Loading branch information
lemeurherve authored Feb 13, 2024
1 parent 1ac5b8a commit e15db37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion IncrementalsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class IncrementalsPlugin {
artifactId: entry.artifactId,
groupId: entry.groupId,
version: entry.version,
hpi: (entry.packaging == "hpi" ? `${entry.artifactId}:incrementals;${entry.groupId};${entry.version}
` : ""),
packaging: entry.packaging,
url: config.INCREMENTAL_URL + entry.path.replace(/[^/]+$/, "")
};
})
Expand Down
27 changes: 21 additions & 6 deletions lib/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ async function getRestClient() {
})
}

function summary(entries) {
const links = `#### Download link${entries.length > 1 ? "s" : ""}:\n${entries.map(entry => `- [${entry.artifactId}](${entry.url})`).join("\n")}`

const hpi = entries
.filter(entry => entry.packaging == "hpi")
.map(entry => `${entry.artifactId}:incrementals;${entry.groupId};${entry.version}`)

// Output the input format section only if there is a plugin, not usable with other type of artifact
return hpi.length == 0 ? links : `${links}\n\n#### Plugin Installation Manager input format: ([documentation](https://github.com/jenkinsci/plugin-installation-manager-tool/#plugin-input-format))\n<pre>${hpi.join("\n")}</pre>`
}

function text(entries) {
const metadata = entries
.map(entry => `&#60;dependency>&#xA; &#60;groupId>${entry.groupId}&#60;/groupId>&#xA; &#60;artifactId>${entry.artifactId}&#60;/artifactId>&#xA; &#60;version>${entry.version}&#60;/version>&#xA;&#60;/dependency>`)
.join("&#xA;")

return `<pre>${metadata}</pre>`
}

export default {
commitExists: async (owner, repo, ref) => {
const github = await getRestClient();
Expand All @@ -39,10 +58,6 @@ 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: ([documentation](https://github.com/jenkinsci/plugin-installation-manager-tool/#plugin-input-format))\n<pre>" + entries.map(entry => entry.hpi).join("") + "</pre>"
const metadata = entries.map(entry => `&#60;dependency>&#xA; &#60;groupId>${entry.groupId}&#60;/groupId>&#xA; &#60;artifactId>${entry.artifactId}&#60;/artifactId>&#xA; &#60;version>${entry.version}&#60;/version>&#xA;&#60;/dependency>`).join("&#xA;")

return github.rest.checks.create({
owner,
repo,
Expand All @@ -53,8 +68,8 @@ export default {
details_url: entries[0].url,
output: {
title: `Deployed version ${entries[0].version} to Incrementals`,
summary: links + "\n\n" + inputFormat,
text: `<pre>&#xA;${metadata}&#xA;</pre>`
summary: summary(entries),
text: text(entries)
}
});
}
Expand Down

0 comments on commit e15db37

Please sign in to comment.