Java Code Examples for hudson.util.VersionNumber#toString()

The following examples show how to use hudson.util.VersionNumber#toString() . 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: ServerInfoAdditionalAnalyticsProperties.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Override
public Map<String, Object> properties(TrackRequest trackReq) {
    Map<String, Object> props = Maps.newHashMap();
    VersionNumber version = Jenkins.getVersion();
    if (version != null && version.toString() != null) {
        props.put("jenkinsVersion", version.toString());
    }
    Plugin plugin = Jenkins.getInstance().getPlugin("blueocean-rest");
    if(plugin != null) {
        props.put("blueoceanVersion", plugin.getWrapper().getVersion());
    }

    return props;
}
 
Example 2
Source File: JenkinsMetadata.java    From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 5 votes vote down vote up
private static String getJenkinsVersion() {
    final VersionNumber jenkinsVersion = Jenkins.getVersion();
    if (jenkinsVersion != null) {
        return jenkinsVersion.toString();
    } else {
        return UNKNOWN;
    }
}
 
Example 3
Source File: BlueOceanConfigStatePreloader.java    From blueocean-plugin with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String getStateJson() {
    StringWriter writer = new StringWriter();
    Jenkins jenkins = Jenkins.getInstance();
    VersionNumber versionNumber = Jenkins.getVersion();
    String version = versionNumber != null ? versionNumber.toString() : Jenkins.VERSION;

    AuthorizationStrategy authorizationStrategy = jenkins.getAuthorizationStrategy();
    boolean allowAnonymousRead = true;
    if(authorizationStrategy instanceof FullControlOnceLoggedInAuthorizationStrategy){
        allowAnonymousRead = ((FullControlOnceLoggedInAuthorizationStrategy) authorizationStrategy).isAllowAnonymousRead();
    }

    String jwtTokenEndpointHostUrl = Jenkins.getInstance().getRootUrl();
    JwtTokenServiceEndpoint jwtTokenServiceEndpoint = JwtTokenServiceEndpoint.first();
    if(jwtTokenServiceEndpoint != null){
        jwtTokenEndpointHostUrl = jwtTokenServiceEndpoint.getHostUrl();
    }
    addFeatures(new JSONBuilder(writer)
        .object()
            .key("version").value(getBlueOceanPluginVersion())
            .key("jenkinsConfig")
            .object()
                .key("analytics").value(Analytics.isAnalyticsEnabled())
                .key("version").value(version)
                .key("security")
                .object()
                    .key("enabled").value(jenkins.isUseSecurity())
                    .key("loginUrl").value(jenkins.getSecurityRealm() == SecurityRealm.NO_AUTHENTICATION ? null : jenkins.getSecurityRealm().getLoginUrl())
                    .key("authorizationStrategy").object()
                        .key("allowAnonymousRead").value(allowAnonymousRead)
                    .endObject()
                    .key("enableJWT").value(BlueOceanConfigProperties.BLUEOCEAN_FEATURE_JWT_AUTHENTICATION)
                    .key("jwtServiceHostUrl").value(jwtTokenEndpointHostUrl)
                .endObject()
            .endObject()
            ) // addFeatures here
        .endObject();

    return writer.toString();
}