Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57636

Show job link and charts even if latest build does not contain results

      I have a build that in some cases is avoided - logs are not produced.

      I would like to be able to compensate reports generation, so no matter if new results are collected, the graph and links are displayed. Currenly only a build that records issues is showing both of those.

      I tried to compensate it by generating report with empty issues collection but then the graph drops to 0

       

      Example - every second build generates report:

      pipeline {
          agent any
          stages {
              stage ('recordIssues') {
                  when { expression { env.BUILD_NUMBER.toBigInteger().mod( 2 ) == 0 } }
                  steps {
                      recordIssues(
                          tools: [
                              intel(pattern: "logs\\**\\*.*"), 
                          ]
                      )
                  }
              }        stage ('compensate') {
                  when { expression { env.BUILD_NUMBER.toBigInteger().mod( 2 ) != 0 } }
                  steps {
                      echo "don't know how..."
                  }
              }
          }    
      }
      

          [JENKINS-57636] Show job link and charts even if latest build does not contain results

          Ulli Hafner added a comment -

          Which links do you mean? The link on the job page or on the build page?

          Ulli Hafner added a comment - Which links do you mean? The link on the job page or on the build page?

          on the job page

          Jakub Pawlinski added a comment - on the job page

          Ulli Hafner added a comment -

          I'm not sure if this is technically possible as the action that shows the links and the trend is created within the action of the build results. If there is no action for a build this does not work. Maybe we should have a flag in recordIssues that creates an empty build action.

          Ulli Hafner added a comment - I'm not sure if this is technically possible as the action that shows the links and the trend is created within the action of the build results. If there is no action for a build this does not work. Maybe we should have a flag in recordIssues that creates an empty build action.

          possibility of empty build action would do just right

          Jakub Pawlinski added a comment - possibility of empty build action would do just right

          Jayanth added a comment -

          Hey I'm interested on working on this issue and i have a question.

          Even if we introduce a flag in recordIssues to force the creation of an empty build action, doesn't that still require recordIssues to be explicitly invoked in the Pipeline DSL for the build action to be created?

          Jayanth added a comment - Hey I'm interested on working on this issue and i have a question. Even if we introduce a flag in recordIssues to force the creation of an empty build action, doesn't that still require recordIssues to be explicitly invoked in the Pipeline DSL for the build action to be created?

          Ulli Hafner added a comment -

          I did not try but I thought that we might use a TransientActionFactory to implement such a feature.

          Here is an example from the workflow plugin:

          @Extension
              public static final class Factory extends TransientActionFactory<WorkflowRun> {
                  public Class<WorkflowRun> type() {
                      return WorkflowRun.class;
                  }
          
                  @NonNull
                  public Collection<? extends Action> createFor(@NonNull WorkflowRun run) {
                      return Collections.singleton(new FlowGraphTableAction(run));
                  }
              }
          

          Maybe we can iterate over all ResultActions in createFor. If we find a ResultAction, then everything is ok, and we return an empty list. If we do not find one, we check the previous build. For each found ResultAction we return the list that is returned by the getProjectActions method. If we do not find an action in the last step we stop (or try up to n builds?).

          Ulli Hafner added a comment - I did not try but I thought that we might use a TransientActionFactory to implement such a feature. Here is an example from the workflow plugin: @Extension public static final class Factory extends TransientActionFactory<WorkflowRun> { public Class <WorkflowRun> type() { return WorkflowRun.class; } @NonNull public Collection<? extends Action> createFor(@NonNull WorkflowRun run) { return Collections.singleton( new FlowGraphTableAction(run)); } } Maybe we can iterate over all ResultActions in createFor. If we find a ResultAction, then everything is ok, and we return an empty list. If we do not find one, we check the previous build. For each found ResultAction we return the list that is returned by the getProjectActions method. If we do not find an action in the last step we stop (or try up to n builds?).

            jay_vts Jayanth
            quas Jakub Pawlinski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: