Skip to content

Commit

Permalink
Display plugin version on home page (#369)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Faracik <[email protected]>
  • Loading branch information
SohamJuneja and janfaracik authored Dec 20, 2024
1 parent 1036666 commit 0761fac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/io/jenkins/plugins/designlibrary/Home.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.jenkins.plugins.designlibrary;

import hudson.Extension;
import hudson.PluginWrapper;
import hudson.model.RootAction;
import java.util.List;
import java.util.Map;
import jenkins.model.Jenkins;

/**
* Entry point to all the UI samples.
Expand Down Expand Up @@ -45,4 +47,13 @@ public UISample getDynamic(String name) {
}
return null;
}

public String getPluginVersion() {
Jenkins jenkins = Jenkins.get();
PluginWrapper plugin = jenkins.getPluginManager().getPlugin("design-library");
if (plugin != null) {

Check warning on line 54 in src/main/java/io/jenkins/plugins/designlibrary/Home.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 54 is only partially covered, one branch is missing
return plugin.getVersion();
}
return "Version not available";

Check warning on line 57 in src/main/java/io/jenkins/plugins/designlibrary/Home.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 57 is not covered by tests
}
}
8 changes: 8 additions & 0 deletions src/main/resources/lib/samples/previous-next-controls.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
<span>${%Home}</span>
</a>
</j:if>
<j:if test="${attrs.previousPage == null and isHome}">
<a href="https://github.com/jenkinsci/design-library-plugin/releases/tag/${it.pluginVersion}"
target="_blank"
class="jenkins-button jenkins-button--tertiary">
<l:icon src="symbol-design-library plugin-design-library" />
${it.pluginVersion}
</a>
</j:if>
</div>
<div class="jenkins-mobile-hide">
<j:if test="${!isHome}">
Expand Down

0 comments on commit 0761fac

Please sign in to comment.