Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badge examples incorrect for some jobs if opened directly from URL #278

Closed
MarkEWaite opened this issue Dec 25, 2023 · 1 comment · Fixed by #290
Closed

Badge examples incorrect for some jobs if opened directly from URL #278

MarkEWaite opened this issue Dec 25, 2023 · 1 comment · Fixed by #290
Labels
bug Incorrect or flawed behavior

Comments

@MarkEWaite
Copy link
Contributor

MarkEWaite commented Dec 25, 2023

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

@MarkEWaite MarkEWaite added the bug Incorrect or flawed behavior label Dec 25, 2023
@MarkEWaite MarkEWaite changed the title Badge examples incorrect for less recent jobs in history Badge examples incorrect for less recent jobs in history if opened from URL directly Dec 25, 2023
@MarkEWaite MarkEWaite changed the title Badge examples incorrect for less recent jobs in history if opened from URL directly Badge examples incorrect for less recent jobs in history if opened directly from URL Dec 25, 2023
@MarkEWaite MarkEWaite changed the title Badge examples incorrect for less recent jobs in history if opened directly from URL Badge examples incorrect for some jobs if opened directly from URL Dec 25, 2023
@MarkEWaite
Copy link
Contributor Author

Bug was created when implementing:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect or flawed behavior
Projects
None yet
1 participant