Giter Site home page Giter Site logo

jenkinsci / embeddable-build-status-plugin Goto Github PK

View Code? Open in Web Editor NEW
166.0 108.0 260.0 726 KB

Embed build status of Jenkins jobs in web pages

Home Page: https://plugins.jenkins.io/embeddable-build-status/

License: MIT License

Java 98.47% Vim Snippet 0.21% CSS 0.10% HTML 1.22%
hacktoberfest

embeddable-build-status-plugin's Introduction

Embeddable Build Status Plugin

This plugin provides customizable badges (similar to shields.io) to any website. A text variant is also available that returns the build status as text.

For each variant there are two URLs available for inclusion:

  • protected exposes the badge to users having at least Read permission on the job:

    Example:
    http://<jenkinsroot>/path/to/job/badge/icon?... (for jobs)
    http://<jenkinsroot>/path/to/job/<buildNumber>/badge/icon?... (for builds)

    If you omit any query parameter the default badge for the job/build will be returned:

    Badge

  • unprotected exposes the badge to users having at least ViewStatus permission on the job

    Example: http://<jenkinsroot>/buildStatus?...

    To select a specific job and build use the query parameters job and build

Customization can be done via query parameters.

Query Parameters

style

Four badge types are supported by the badge variant:

plastic

Badge (default)

Customized Badge (customized)

flat (default)

Badge (default)

Customized Badge (customized)

flat-square

Badge (default)

Customized Badge (customized)

ball-<size>

This style returns the standard Jenkins "balls".

Supported sizes are: 16x16, 24x24, 32x32 and 48x48 (and probably more... just try).

Examples: ball-16x16 or ball-32x32

Note: If you are using this style all other query parameters will have no effect.

config

You can add pre-customized badge configurations via pipeline script (see "DSL" below).

subject and status

The customized examples above uses the following query parameters:

?subject=Custom Text&status=My passing text

color and animatedOverlayColor

You can override the color using the following valid color values:

  • one of the values: red, brightgreen, green, yellowgreen, yellow, orange, lightgrey, blue
  • a valid hexadecimal HTML RGB color without the hashtag (e.g. FFAABB).
  • any valid SVG color name

job

Note: This parameter is only supported for the unprotected URL!

The path for the selected job or any selector implemented via JobSelectorExtensionPoint

If you omit this parameter you can customize any "untethered" badge you like.

Important

The job selector string must be URL escaped.
If you are using Multibranch Pipelines the branch within the selector needs to be URL encoded twice.

Example
?job=path/to/job/branch/path ❌
would become
?job=path%2Fto%2Fjob%2Fbranch%252Fpath βœ”

build

Select the build. This parameter is supported for the protected and unprotected URL! For the unprotected URL use the job parameter is also required!

Selectors

Allowed selectors are:

  • Build-ID (integer)

  • relative negative Build-Index (0 = last, -1 = previous, -2 ...)

  • Selector via the following Rule:

    (last|first)[Failed|Successful|Unsuccessful|Stable|Unstable|Completed][:${params.<BuildParamerName>=<BuildParameterValue>}]

    • (...) is required
    • [...] is optional

    Examples:

    • last
    • first
    • lastStable
    • firstCompleted
    • lastSuccessful:${params.BRANCH=master}

Concatenation

All those selectors can be concatenated as comma separated list:

build=last,-10,firstSuccessful:${params.BRANCH=master}

This searches in the last 10 runs for the first successful build of the master branch (provided the Build Parameter BRANCH exists).

Note: If you are using Multibranch Pipelines the branch name within the selector needs to be URL encoded twice (see job for further information).

link

Provide a link to be opened on clicking on the badge.

Parameter Resolver

The query parameters subject, status, color, animatedOverlayColor and link support the usage of variables like ?subject=Build ${variable}

Available builtin variables are:

  • buildId, buildNumber, displayName, description, duration, and startTime

  • params.<BuildParameterName> where <BuildParameterName> matches any Parameter used for running the job.

    Note: If the build parameter is not set you can use the following syntax to use a fallback value: params.<BuildParameterName>|<FallbackValue>

Example: ?subject=Build ${params.BUILD_BRANCH|master} (${displayName})

Pipeline (DSL)

/**
 * Adds a badge configuration with the given id.
 * minimal params
 *
 * id: A unique id for the configuration
 */
addEmbeddableBadgeConfiguration(id: <id>)

/**
 * all params
 *
 * id: A unique id for the configuration
 * subject: A subject text
 * status: A status text
 * color: A valid color (RGB-HEX: RRGGBB or valid SVG color name)
 * animatedOverlayColor: A valid color (RGB-HEX: RRGGBB or valid SVG color name)
 * link: The link to be opened upon clicking.
 */
addEmbeddableBadgeConfiguration(id: <string>,
                                subject: <string>,
                                status: <string>,
                                color: <string>,
                                animatedOverlayColor: <string>,
                                link: <string>)

This function returns a configuration object.

Example

def win32BuildBadge = addEmbeddableBadgeConfiguration(id: "win32build", subject: "Windows Build")

def RunBuild() {
    echo 'Sleeping instead of running the build'
    sleep 10
}

pipeline {
    agent any
    stages {
        stage('Building') {
            steps {
                script {
                    win32BuildBadge.setStatus('running')
                    try {
                        RunBuild()
                        win32BuildBadge.setStatus('passing')
                    } catch (Exception err) {
                        win32BuildBadge.setStatus('failing')

                        /* Note: If you do not set the color
                                 the configuration uses the best status-matching color.
                                 passing -> brightgreen
                                 failing -> red
                                 ...
                        */
                        win32BuildBadge.setColor('pink')
                        error 'Build failed'
                    }
                }
            }
        }
    }
}

You can use the config query parameter to reference the win32build id:

http://<jenkinsroot>/path/to/job/<buildNumber>/badge/icon?config=win32build

http://<jenkinsroot>/buildStatus/icon?job=...&build=...&config=win32build

Passing Failing

Text variant

The text variant returns a string representing the build status. Build status strings returned by the text variant include:

  • Success - the build succeeded
  • Failed - the build failed
  • Unstable - the build succeeded but one or more tests failed
  • Aborted - the build was canceled
  • Not built - the build has not yet run

More details of the valid build results are available in the Jenkins javadoc.

Extension points for plugin developers

A Jenkins Extension annotation allows Jenkins to discover classes, instantiate them, and register them in global lists of implementations of their supertypes and interfaces. The plugin provides several extension points that plugin developers can use to extend the behavior of the plugin. The Jenkins developer documentation provides more details on extensions and how to use them.

JobSelectorExtensionPoint

The JobSelectorExtensionPoint allows custom job selector implementations.

RunSelectorExtensionPoint

The RunSelectorExtensionPoint allows custom run selector implementations.

ParameterResolverExtensionPoint

The ParameterResolverExtensionPoint allow custom ${<Parameter>} resolver implementations.

embeddable-build-status-plugin's People

Contributors

abhishekmaity avatar alecharp avatar basil avatar brantone avatar christiangalsterer avatar daniel-beck avatar dependabot[bot] avatar diginc avatar imod avatar jenkinsci-cert-ci avatar jglick avatar jvelo avatar kalarani-tw avatar kohsuke avatar markewaite avatar mgedmin avatar mondalsayantan avatar ndeloof avatar notmyfault avatar offa avatar okhan-coder avatar olivergondza avatar rozza avatar sghill-rewrite avatar sridamul avatar stefanspieker avatar subhojit-dey1234 avatar svanoort avatar thomas-dee avatar vandit1604 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

embeddable-build-status-plugin's Issues

Build status for specific branch

Hey there,

Is it possible have a place define a specific branch name which the badge status to be reflect on?

For example:
https://jenkins.gedmin.as/buildStatus/branchName/icon

Thanks.

Build url is wrong

I haven't setup a domain for my Jenkins - the ip is internal instead of the external

image

Unprotected URL and self-signed SSL

I am using the Jenkins self-signed SSL, which typically gives a wanring in the browser when you access it.

This is also stopping me from accessing the unprotected URL if for exmaple, I embed the image in a MD file

Badge examples incorrect for some jobs if opened directly from URL

Jenkins and plugins versions report

Pipeline job that alternates success, failure, and unstable
def win32BuildBadge = addEmbeddableBadgeConfiguration(id: "win32build", subject: "Windows Build")

def RunBuild() {
  echo 'Sleeping instead of running the build'
  sleep 10
  int buildNumber = env.BUILD_ID as int
  if ((buildNumber % 3) == 0) {
      error("Failing for fun")
  }
  if ((buildNumber % 3) == 1) {
      unstable("Unnstable for entertainment")
  }
}

pipeline {
  agent any
  stages {
      stage('Building') {
          steps {
              script {
                  win32BuildBadge.setStatus('running')
                  try {
                      RunBuild()
                      win32BuildBadge.setStatus('passing')
                  } catch (Exception err) {
                      win32BuildBadge.setStatus('failing')

                      /* Note: If you do not set the color
                               the configuration uses the best status-matching color.
                               passing -> brightgreen
                               failing -> red
                               ...
                      */
                      win32BuildBadge.setColor('pink')
                      error 'Build failed'
                  }
              }
          }
      }
  }
}

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux controller as described in my docker-lfs repository

Reproduction steps

  1. Run the job at least 3 times so that there are jobs results that include success, failure, and unstable
  2. Open a specific build of the job (for example, build 1) and click the "Embeddable build status" link on the page. Note that the examples are displayed correctly.
  3. Modify the URL in the web browser to use a different build number (for example, build 2) and press enter to load that page. Note that the example is not displayed correctly. It includes a broken image and null-refererbadge/icon?subject=Custom%20Subject&status=Any%20State&color=darkturquoise

Expected Results

Example should be correct on the page

Actual Results

a broken image and null-refererbadge/icon?subject=Custom%20Subject&status=Any%20State&color=darkturquoise

screencapture-mark-pc2-markwaite-net-8080-job-embeddable-status-example-pipeline-7-badge-2023-12-24-23_10_28-edit

Anything else?

No response

Are you interested in contributing a fix?

No response

Build Status for Multibranch Jobs

Hey guys,

any chance to have the embeddable build status in Multibranch jobs / Github Organization Folders? Right now I don't see any button for that.

I'd be happy to provide this if you guys give me a hint where to start.

Cheers,
Jan

Display the image on the build information page

Describe your use-case which is not covered by existing documentation.

Would it be possible to provide sample code on how to update the build status page.
Either how to replace the ball or add it to the description.

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response

Are you interested in contributing to the documentation?

No response

NoClassDefFoundError on v2.0

Master version : 2.138.2
JDK: 1.8.0_192
OS: Rhel6

I'm seeing this stacktrace on every page after upgrading to v2.0 of the plugin

Stack trace
java.lang.NoClassDefFoundError: org/jenkinsci/plugins/badge/PublicBadgeAction
	at com.ms.msde.jenkins.plugin.RuleFactory$2.createRule(RuleFactory.java:413)
	at com.ms.msde.jenkins.plugin.TAMAclImpl.checkPermissionInTAM(TAMAclImpl.java:153)
	at com.ms.msde.jenkins.plugin.TAMAclImpl.access$000(TAMAclImpl.java:33)
	at com.ms.msde.jenkins.plugin.TAMAclImpl$1.load(TAMAclImpl.java:127)
	at com.ms.msde.jenkins.plugin.TAMAclImpl$1.load(TAMAclImpl.java:123)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3568)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2350)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2313)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2228)
Caused: com.google.common.util.concurrent.ExecutionError
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2232)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3965)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3969)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4829)
	at com.google.common.cache.LocalCache$LocalManualCache.getUnchecked(LocalCache.java:4834)
	at com.ms.msde.jenkins.plugin.TAMAclImpl.hasPermission(TAMAclImpl.java:194)
	at hudson.security.SidACL._hasPermission(SidACL.java:70)
	at hudson.security.SidACL.hasPermission(SidACL.java:52)
	at hudson.security.ACL.hasPermission(ACL.java:87)
	at hudson.model.AbstractItem.getTarget(AbstractItem.java:944)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:693)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:864)
	at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:248)
	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:734)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:864)
	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:668)
	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
Caused: javax.servlet.ServletException: Servlet execution threw an exception
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:314)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
	at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:243)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at com.smartcodeltd.jenkinsci.plugin.assetbundler.filters.LessCSS.doFilter(LessCSS.java:47)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.plugins.audit_trail.AuditTrailFilter.doFilter(AuditTrailFilter.java:92)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239)
	at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215)
	at net.bull.javamelody.PluginMonitoringFilter.doFilter(PluginMonitoringFilter.java:88)
	at org.jvnet.hudson.plugins.monitoring.HudsonMonitoringFilter.doFilter(HudsonMonitoringFilter.java:114)
	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:64)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jenkinsci.plugins.remote_user_auth.RemoteUserSecurityRealm$1.doFilter(RemoteUserSecurityRealm.java:189)
	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at com.ms.webeng.tomcat.PingValve.invoke(PingValve.java:368)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at com.ms.webeng.tomcat.ThreadNameValve.invoke(ThreadNameValve.java:61)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
	at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:844)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1477)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

Build status for views

Hey

I have many jobs to test one program.
Can you create a badge for a view (list view)?

Passing: when all jobs blue
Falling: when one yellow or red
(Unknown: as you wish)

Parameter name with spaces

I have a parameter like following:

stringParam {
  trim(true)
  name('Version to install')
  defaultValue('')
  description('The version to install.')
}

Which I can use in Jenkinsfiles like:

echo params.'Version to install'

However, I'm trying to use it as a variable in the ?subject=, but I can't make it work. I think I tried everything already.

Any help would be appreciated.

Adding Jenkins logo to build status

Generally repositories have multiple CI configured. Without a logo it would be a little difficult to differentiate between different CI statuses. I would like to add support for it. Can we do it?

Currently Jenkins badge looks like -> Build Status

Here's an example how adding a logo would look like -> Travis

If you agree let me know I will start working on it.

Javadoc errors

From #17 (comment):

By the way I needed to use JDK 7 to cut the release since you have Javadoc mistakes which are treated as errors by JDK 8:

…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:54: error: tag not allowed here: <li>
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1 <br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:54: error: tag not allowed here: <li>
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1 <br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:54: error: self-closing element not allowed
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1 <br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:55: error: self-closing element not allowed
* <br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:59: error: tag not allowed here: <li>
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME]&build=[BUILDNUMBER] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1&build=5<br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:59: error: semicolon missing
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME]&build=[BUILDNUMBER] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1&build=5<br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:59: error: tag not allowed here: <li>
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME]&build=[BUILDNUMBER] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1&build=5<br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:59: error: semicolon missing
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME]&build=[BUILDNUMBER] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1&build=5<br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:59: error: self-closing element not allowed
* <li>http://localhost:8080/buildstatus/icon?job=[JOBNAME]&build=[BUILDNUMBER] <li>e.g. http://localhost:8080/buildstatus/icon?job=free1&build=5<br/>
^
…/src/main/java/org/jenkinsci/plugins/badge/PublicBadgeAction.java:60: error: self-closing element not allowed
* <br/>
^

builtin variables "description" does not get value

Jenkins and plugins versions report

Environment
Paste the output here

What Operating System are you using (both controller, and any agents involved in the problem)?

  • macOS 12.3
  • Jenkins 2.341

Reproduction steps

trying to use the builtin variables in a url,
buildId, buildNumber, displayName, description, duration, and startTime

this works:
http://name.server.com:8080/job/JobName/22/badge/icon?subject=XCTest&status=${displayName}
http://name.server.com:8080/job/JobName/badge/icon?subject=XCTest&status=${displayName}

this does not work using description
http://name.server.com:8080/job/JobName/22/badge/icon?subject=XCTest&status=${description}
http://name.server.com:8080/job/JobName/badge/icon?subject=XCTest&status=${description}

I searched the code, seems it is correct there,


but why it failed to get the description for the task run...

thanks !

Expected Results

a task run has description set after the task complete, say "122 tests failed",
expecting the badge will be [XCTest: 122 tests failed]

Actual Results

now it shows as [XCTest: description]

Anything else?

No response

Document the different text status strings

It may be that I'm just slightly blind today, but I couldn't find a list of the possible text strings that can be returned by the /text status variant.
Implementing scripts that use it would be very much easier if I knew what results I can expect. πŸ™‚

Unprotected URLs work for Anonymous user even without ViewStatus permission

Version report

Jenkins and plugins versions report:

Jenkins: 2.303.1
OS: Linux - 4.15.0-163-generic
---
ace-editor:1.1
ansicolor:1.0.0
ant:1.11
antisamy-markup-formatter:2.1
apache-httpcomponents-client-4-api:4.5.13-1.0
authentication-tokens:1.4
bootstrap4-api:4.6.0-3
bootstrap5-api:5.1.0-3
bouncycastle-api:2.24
branch-api:2.6.5
build-monitor-plugin:1.12+build.201809061734
build-timestamp:1.0.3
build-token-root:1.7
caffeine-api:2.9.2-29.v717aac953ff3
calendar-view:0.3.1
checks-api:1.7.2
cloudbees-folder:6.16
command-launcher:1.6
compact-columns:1.13
conditional-buildstep:1.4.1
config-file-provider:3.8.1
configurationslicing:1.52
console-badge:1.1
copyartifact:1.46.1
credentials:2.5
credentials-binding:1.27
cron_column:1.4
display-url-api:2.3.5
docker-build-step:2.8
docker-commons:1.17
docker-workflow:1.26
durable-task:1.39
dynamicparameter:0.2.0
echarts-api:5.1.2-11
email-ext:2.83
embeddable-build-status:2.0.3
exclusive-execution:0.8
external-monitor-job:1.7
font-awesome-api:5.15.4-1
git:4.8.2
git-client:3.9.0
git-parameter:0.9.13
git-server:1.10
github:1.34.1
github-api:1.123
greenballs:1.15.1
handlebars:3.0.8
jackson2-api:2.12.4
jacoco:3.3.0
javadoc:1.6
jdk-tool:1.5
jobConfigHistory:2.28.1
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.52
ldap:2.7
lockable-resources:2.11
m2release:0.16.2
mailer:1.34
mapdb-api:1.0.9.0
matrix-auth:2.6.8
matrix-project:1.19
maven-plugin:3.12
momentjs:1.1.1
next-executions:1.0.15
nodejs:1.4.0
nodelabelparameter:1.9.0
okhttp-api:3.14.9
pam-auth:1.6
parameterized-trigger:2.41
pipeline-build-step:2.15
pipeline-graph-analysis:1.11
pipeline-input-step:2.12
pipeline-milestone-step:1.3.2
pipeline-model-api:1.9.1
pipeline-model-definition:1.9.1
pipeline-model-extensions:1.9.1
pipeline-rest-api:2.19
pipeline-stage-step:2.5
pipeline-stage-tags-metadata:1.9.1
pipeline-stage-view:2.19
plain-credentials:1.7
plugin-util-api:2.4.0
popper-api:1.16.1-2
popper2-api:2.9.3-1
preSCMbuildstep:0.3
rebuild:1.32
release:2.11
resource-disposer:0.16
run-condition:1.5
scm-api:2.6.5
script-security:1.78
scriptler:3.3
show-build-parameters:1.0
snakeyaml-api:1.29.1
sonar:2.13.1
ssh:2.6.1
ssh-agent:1.23
ssh-credentials:1.19
ssh-slaves:1.33.0
sshd:3.1.0
structs:1.23
timestamper:1.13
token-macro:266.v44a80cf277fd
toolenv:1.2
trilead-api:1.0.13
validating-string-parameter:2.8
view-job-filters:2.3
windows-slaves:1.8
workflow-aggregator:2.6
workflow-api:2.46
workflow-basic-steps:2.24
workflow-cps:2.93
workflow-cps-global-lib:2.21
workflow-durable-task-step:2.39
workflow-job:2.41
workflow-multibranch:2.26
workflow-scm-step:2.13
workflow-step-api:2.24
workflow-support:3.8
ws-cleanup:0.39
  • What Operating System are you using (both controller, and any agents involved in the problem)?
Ubuntu 18.04.5 LTS

Reproduction steps

  • Select Security Realm -> "Unix user/group database" (group sshd).
  • Use "Matrix-based security" authorization.
  • Remove all permissions from predefined "Anonymous Users" and "Authenticated Users", including ViewStatus.
  • Go to any job, Embeddable Build Status section. Copy the unprotected URL.
  • Open copied URL in the incognito tab (i.e. without authorization) or simply get it with CURL.

Results

Expected result: the URL would not show the job status, since unauthorized (i.e. anonymous) users do not have ViewStatus (or any at all) privileges.

Actual result: the link shows the proper status icon for the latest job build.

I was under impression, that unprotected URL should only work for anonymous users, if the VIewStatus or Read (job) privileges are granted. But they are empty, yet anyone can view the job build status icon.

copy build status URL from Jenkins branch/job page

What feature do you want to see added?

Hi,

I love this plugin however I find building the URL quite cumbersome.

A build status icon could be included on the Jenkins branch page and on the job page. It should copy the build status URL to the clipboard on the user's click.

Upstream changes

No response

Support API Token in query params

What feature do you want to see added?

Would be nice if an API token that a user generates could be used in the request URL. This way users with permission can embed the badge in situations when the cookie is not available (incognito mode), Companies' Intranets, etc. And administrators do not wish (or do not know) about opening up permissions to anonymous (which could be scary).

Upstream changes

No response

Are you interested in contributing this feature?

I don't know enough about Jenkins to be of use.

Instructions on how to add a link with query parameters

Describe your use-case which is not covered by existing documentation.

I want to use a build badge with a link to add a direct link to checkmark. Checkmarx sends me a link (in XML) which I then use with setLink

The problem is that the link has query parameters and the & is converted to &amp; by the time I click on the badge

How do I pass a & as part of the link?

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response

Customizable badge text

We have several different builds running for a given project: tests on every commit, slower tests that run nightly, tests to see if we're breaking related downstream repositories, etc. Would it be possible to make the status icon text customizable so several badges could live side by side without confusion?

Build status for pipeline building multiple projects and branches

Jenkins and plugins versions report

Environment

I don't have access to jenkins settings

What Operating System are you using (both controller, and any agents involved in the problem)?

I don't have access to jenkins settings

Reproduction steps

  1. Pipeline that builds multiple projects and branches on those projects. I have a description with an html table with build status for the latest build per project/branch
  2. My current parametrization for the icons is: https://jenkins....com/job/my-generic-pipeline/badge/icon?build=lastCompleted:$%7bparams.TARGET=dev%7d,lastCompleted:$%7bparams.PROJECT=my-ui-project%7d where TARGET and PROJECT are build parameters defined either from UI or from webhooks

Expected Results

I expect to get accurate build status per project and branch

Actual Results

All icons are shown, but the status is not accurate. Most of them show PASSING, even for projects that only one of the branches have been executed (i.e. dev did pass, main never ran). Or some have the opposite to what I expected, when dev failed and main succeeded, the icons show the opposite.

Anything else?

Is there a way to filter using environment variables I set during the plan execution? env.SOMETHING is set based on several situations, and I would like to have a build status icon for those too.

MissingMethodException for addEmbeddableBadgeConfiguration()

I have a Jenkins of ver. 2.190.1 with "Embeddable Build Status" plug-in of ver. 2.0.2 installed.

When trying to invoke a addEmbeddableBadgeConfiguration() function from the pipeline script:

def myCustomBadge = addEmbeddableBadgeConfiguration(id: "myCustomBadge")

it fails to evaluate the groovy script. Full stack trace:

ERROR: Failed to evaluate groovy script.
groovy.lang.MissingMethodException: No signature of method: Script1.addEmbeddableBadgeConfiguration() is applicable for argument types: (java.util.LinkedHashMap) values: [[id:myCustomBadge]]
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:160)
	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:142)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:162)
	at org.kohsuke.groovy.sandbox.impl.Checker$checkedCall.callStatic(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
	at Script1.run(Script1.groovy:1)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runScript(GroovySandbox.java:162)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:368)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:312)
	at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:406)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
	at hudson.model.Build$BuildExecution.post2(Build.java:186)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
	at hudson.model.Run.execute(Run.java:1840)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)

Do you have any hints on what might be wrong with my setup?


One more observation from "Pipeline Syntax" helper. Snippet generation fails with:

no public field β€˜id’ (or getter method) found in class org.jenkinsci.plugins.badge.dsl.AddEmbeddableBadgeConfigStep

2020-02-19_13-15-29

Badge in build from pull request shows wrong badge

I want to be able to access badges created in builds triggered from pull requests, just like I'm able to access a regular builds' badge by build number. When accessing the badge from the PR build URL, the badge shown is the badge from the last regular build (even if I remove badge creation from the jenkinsfile altogether).

Create Bug-Report

  • [x]
  • ### Version report
  • [ ]
  • Jenkins and plugins versions report:
  • [X]
  • [ ]
  • ```
  • Copy/paste here....
  • ```
  • [X]
  • - What Operating System are you using (both controller, and any agents involved in the problem)?
  • [ ]
  • ```
  • Paste here
  • ```
  • [ ]
  • ### Reproduction steps
  • [ ]
  • <!--
  • - Write bullet-point reproduction steps.
  • - Be explicit about any relevant configuration, jobs, build history, user accounts, etc., redacting confidential information as needed.
  • - The best reproduction steps start with a clean Jenkins install, perhaps a docker run command if possible.
  • - Use screenshots where appropriate, copy textual output otherwise. When in doubt, do both.
  • - Include relevant logs, debug if needed - https://www.jenkins.io/doc/book/system-administration/viewing-logs/
  • -->
  • [ ]
  • - Step 1...
  • - Step 2...
  • [ ]
  • ### Results
  • [X]
  • Expected result:
  • [X]
  • [X]
  • Actual result:
  • [ X]

No way to filter a build with multiple parameters

Hi. I couldn't find a way to filter a build by two or more parameters (AND condition).

Example:
PARAM1=value1
PARAM2=value2

I would expect something like:
last:${params.PARAM1=value1},${params.PARAM2=value2}

Error HTTP 404 for unprotected link

Error HTTP 404 for unprotected link

I get the Error HTTP 404 when trying to get the unprotected link Build Status Icon. It happened on all my "GitHub Organization" and "Multibranch Pipeline" Jenkins Projects with branches containing '/' in their name. For example if the branch name is release/1.2.8

Here is my Jenkins Setup for the explanation of this issue.

  • GitHub Organization (oss)
  • contain the repository (zlib)
  • with two branches: master and release/1.2.8

The links provided by the plugin are:

master

release/1.2.8

Results

  • As expected, the Build Status Icon is displayed for master branch.

But not for the release/1.2.8 branch. This is the error message when trying to access the link with my web browser:

This jenkins.example.com page can’t be found
No webpage was found for the web address: https://jenkins.example.com/buildStatus/icon?job=oss/zlib/release%2F1.2.8
HTTP ERROR 404

Please add .adoc snippets

I love that you provide pre-configured code in various formats to embed the badges in our pages.
I've started using the .adoc format for readmes and would love to have that syntax ready-made instead of having to re-format it (which I'm still figuring out).
Thanks!

RFC: support for ENV to filter out PR builds

What feature do you want to see added?

My job runs builds against commits into the associated branch and PR builds against the associated branch,
but I have no capable filter to remove PR builds.

It would be great to use something like ENV vars (vs just build params):

/buildStatus/icon?job=foo%2Fbar&build=lastCompleted:${env.TRIGGER_BRANCH=main}

such that my PR builds in my job are not used for the badge.

Upstream changes

No response

Improve automated test coverage

Increase automated test coverage

Automated test coverage of the embeddable build status plugin is quite low. Improve the automated test coverage by submitting pull requests with new automated tests.

Review current coverage

Review the current test coverage with the commands:

Linux

$ mvn -P enable-jacoco clean install jacoco:report
$ xdg-open target/site/jacoco/index.html

Windows

C:\Users\Yourname > mvn -P enable-jacoco clean install jacoco:report
C:\Users\Yourname > start target\site\jacoco\index.html

More information is in the "code coverage" section of the contributing guide.

Create a new test for a class that is not well covered

Most integrated development environments have tools that will create a test stub that is a good beginning. Apache Netbeans has "Create / Update tests" . JetBrains IntelliJ has "Create tests". Visual Studio Code has the "Extension Pack for Java".

Use the IDE or your own coding to create a test for one of the classes that is not well covered by tests.

Keep the test small so that the pull request is easy to review.

Ability to show lastSuccessful OR lastFailed

We have a use case where we want to ignore all builds that were marked as "skipped" or "not run" and just display pipeline jobs that had succeeded or failed. Is there any way to perform this action or implement it?

Thanks for the badge, our team really appreciates it!

Announcement: ci.jenkins.io badges will be deactivated

UPDATE:

@MarkEWaite and @darinpope adopted the plugin, thus it doesn't have to be removed from ci.jenkins.io, you'll be able to continue using it.

As indicated in jenkins-infra/helpdesk#3013

plugins.jenkins.io/embeddable-build-status is not actively maintained. The Jenkins security team had to address multiple vulnerabilities in jenkins.io/security/advisory/2022-06-22 to protect Jenkins project infrastructure. While the maintainer (thomas-dee) was happy to let us release the fixes we wrote, i.e. was responsive via email, he also told us he has no capacity to assist in any way. This is unsustainable. Consider removing the plugin from ci.jenkins.io.

We (the Jenkins Infrastructure team) will proceed to the removal of the embeddable-build-status plugin from https://ci.jenkins.io

As a result, all badges using this plugin with a markup containing https://ci.jenkins.io/buildStatus/ (builds from the public instance https://ci.jenkins.io) won't work anymore.

An alternative has been proposed to put in place a self-hosted shield.io instance which would allow serving badges from ci.jenkins.io without this plugin.

Nothing change for badges retrieved from your own instance(s).

A pull request to indicate this deprecation/removal will be done on this repository, and other will be opened on the ~170 concerned repositories.

We invite you to follow the helpdesk issue for progress and/or comments.

Broken image in github

I have a simple build status link in my readme.md to our local Jenkins server. If I preview readme.md in a Markdown viewer in VS Code, it renders fine. I also have a link on a Confluence page, and that renders fine.

In GitHub however it fails to render, only showing a broken image.

The link is very simple, of this format...

[![Build Status](http://jenkins-server:8080/buildStatus/icon?job=our-project%2Fmaster)](http://jenkins-server:8080/blue/organizations/jenkins/our-project/activity?branch=master)

I have also tried with simple HTML 'img' tags, but doesn't work.

If I put the image link direct into the browser it renders fine.

I should add that we're using GitHub Enterprise, hosted on-premises but then it can see our Jenkins server, plus it works in our Confluence which is cloud hosted (i.e. the browser can see the Jenkins server so works fine).

Add URLs for Bitbucket

Hi,

I cannot use "Markdown"-URLs from embeddable-build-status-plugin in Bitbucket, as
Bitbucket's image markdown syntax is somewhat different:

![Alt text](http://www.addictedtoibiza.com/wp-content/uploads/2012/12/example.png "Optional title")

Please add extra URLs "Bitbucket" at "Embeddable Build Status Icon" page.

ball-<size> not working

Hi,

I am using "Embeddable Build Status" V2.0 in Jenkins 2.150.3, running on Linux.
With this setup, the ball- feature it is not working ; balls are not rendered at all.

ball_ko

Plain link url to job should be linked to job url by default

Hello there,
thanks a lot for this great tool.

Current version allow usage of clickable links.
It works well if I am using a "config" whiting a pipeline.

I am currently also using plain link (protected and unprotected) for my build statuses:
https://{jenkins_root}/job/Tests/job/{job_name}/badge/icon
https://{jenkins_root}/buildStatus/icon?job={job_name}

When I use these link into a wiki page and currently I do not have the possibility to click.
In my opinion, url link to job should be available by default.

New release

Please, make new release to allow users use latest changes in plugin like text endpoint.

Update appears to have broken github readme links displaying "not run"

Badges no longer display correctly in the mk64 decomp repo readme. It says "not run" instead of showing the percentage decomped.

It appears the plugin was recently updated to v2.0.4 (released five days ago).
The repo has not modified the links or the build system in-charge of producing the badges
If I manually go to the links in the readme the badges display correctly.

https://github.com/n64decomp/mk64

Links are formatted as such:

[![Build Status](https://ci.valandil.ca/buildStatus/icon?job=mk64%2Fmaster&config=codeProgress)](https://ci.valandil.ca/job/mk64/job/master/)

Running selector on boolean build param

Which is the proper way to use selectors against boolean build params? I've tried this:

https://<jenkins_url>/badge/icon?subject=Boolean param ${params.myBoolean}&build=last,-10,lastCompleted:${params.myBoolean=true}

As the params.myBoolean in the subject spits true or false, I assumed that I could use that same string in the selector, but it doesn't seem to be working correctly (selector evaluation is defaulting to true).

I imagine that https://github.com/jenkinsci/embeddable-build-status-plugin/blob/master/src/main/java/org/jenkinsci/plugins/badge/extensions/BuildParameterRunSelectorExtension.java#L41 this line is where the evaluation is taking place, but I can't see anything wrong with that, unless value.getValue().toString() is doing something completely different from what I think πŸ€”

Disabled Status

I see in version 1.2, back in March of 2013, the decision was made to utilize the "Unknown" image to represent the disabled status for a build. I would argue that the "disabled" status is a valid status in, and of, itself and should therefore not be classified as "unknown." Would it be possible to utilize a "Disabled" image for the "disabled" status? I agree with the decision to use the "light-gray" coloration to represent this status.

Thank you...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.