Java Code Examples for jenkins.model.Jenkins#RESOURCE_PATH

The following examples show how to use jenkins.model.Jenkins#RESOURCE_PATH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhabricatorPlugin.java    From phabricator-jenkins-plugin with MIT License 6 votes vote down vote up
public static String getIconPath(String icon) {
    if (icon == null) {
        return null;
    }
    if (icon.startsWith("/")) {
        return icon;
    }

    // Try plugin images dir, fallback to Hudson images dir
    PluginWrapper wrapper = Jenkins.getInstance().getPluginManager().getPlugin(PhabricatorPlugin.class);

    boolean pluginIconExists =
            (wrapper != null) && new File(wrapper.baseResourceURL.getPath() + "/images/" + icon).exists();
    return pluginIconExists ? "/plugin/" + wrapper.getShortName() + "/images/" + icon :
            Jenkins.RESOURCE_PATH + "/images/16x16/" + icon;
}
 
Example 2
Source File: AnchoreProjectAction.java    From anchore-container-scanner-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public String getIconFileName() {
  return Jenkins.RESOURCE_PATH + "/plugin/anchore-container-scanner/images/anchore.png";
}
 
Example 3
Source File: AnchoreAction.java    From anchore-container-scanner-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public String getIconFileName() {
  return Jenkins.RESOURCE_PATH + "/plugin/anchore-container-scanner/images/anchore.png";
}
 
Example 4
Source File: StatusAction.java    From jenkins-status-badges-plugin with MIT License 4 votes vote down vote up
@Override
public String getIconFileName()
{
    return Jenkins.RESOURCE_PATH + "/plugin/status-badges/images/24x24/shield.png";
}
 
Example 5
Source File: StatusImage.java    From jenkins-status-badges-plugin with MIT License 4 votes vote down vote up
StatusImage( String subject, String status, String colorName, String style )
    throws FontFormatException, IOException
{
    etag = Jenkins.RESOURCE_PATH + '/' + subject + status + colorName;

    if ( style == null )
    {
        style = "default";
    }

    URL image =
        new URL( Jenkins.getInstance().pluginManager.getPlugin( "status-badges" ).baseResourceURL, "status/"
            + style + ".svg" );
    InputStream s = image.openStream();

    double[] widths = { measureText( subject ) + 10, measureText( status ) + 10 };

    String color = colors.get( colorName );

    if ( color == null )
    {
        color = '#' + colorName;
    }

    String fullwidth = String.valueOf( widths[0] + widths[1] );
    String blockPos = String.valueOf( widths[0] );
    String blockWidth = String.valueOf( widths[1] );
    String subjectPos = String.valueOf( ( widths[0] / 2 ) + 1 );
    String statusPos = String.valueOf( widths[0] + ( widths[1] / 2 ) - 1 );

    try
    {
        payload =
            IOUtils.toString( s, "utf-8" ).replace( "{{fullwidth}}", fullwidth ).replace( "{{blockPos}}", blockPos ).replace( "{{blockWidth}}",
                                                                                                                              blockWidth ).replace( "{{subjectPos}}",
                                                                                                                                                    subjectPos ).replace( "{{statusPos}}",
                                                                                                                                                                          statusPos ).replace( "{{subject}}",
                                                                                                                                                                                               subject ).replace( "{{status}}",
                                                                                                                                                                                                                  status ).replace( "{{color}}",
                                                                                                                                                                                                                                    color );
    }
    finally
    {
        IOUtils.closeQuietly( s );
    }

    length = Integer.toString( payload.length() );
}