How can I capture and manipulate plugin java instance(e.g stage-view) using groovy in declarative pipeline?

I am using staging view plugin to see how much it takes to run my stages. But when I trigger a downstream build and the downstream build waits in the queue, my upstream build cannot find out that downstream build is in queue and counts the time as if it is building. What I wanna do is to capture stage view instance via groovy script in declarative jenkinsfile and change its state to stop it counting the time until downstream build starts to run. I tried to get plugin instance with the jenkinsfile below but it returns null. I donÔÇÖt know what I am asking is feasible think to do. Any commands would be appriciated.

import com.cloudbees.workflow.ui.view.*;
def plugin = Jenkins.get().getPlugins(WorkflowStageViewAction);
println plugin.getDisplayName();

pipeline {
  agent any

  options {

  parameters {
    choice(name: 'ENVIRONMENT', choices: ['dev', 'prod'], description: 'Select environment.')
    string(name: 'BRANCH', defaultValue: 'master', description: 'Write name of the branch.')

  stages {        
            sh "echo example"


Do not do what you are attempting. If Stage View does not natively record pauses from the build step then there is no workaround at the pipeline level.

1 Like

Is it technically not possible or it would have so much unexpected side effects?

Probably both. This is something to do at the plugin level.

1 Like