Answers: <p>By default, there is no way to visualize skipped stages in the Jenkins UI.  <a href="https://issues.jenkins.io/browse/JENKINS-54322?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel" rel="nofollow noreferrer">See this issue report on the Jenkins JIRA about visualizing skipped stages</a>.</p>
  <p>There are a few workarounds that I'm aware of:</p>
  <p>You can <a href="https://www.jenkins.io/doc/book/managing/script-approval/#groovy-sandbox" rel="nofollow noreferrer">disable the Groovy sandbox</a> to allow importing the aforementioned class.</p>
  <p>You can also use the <a href="https://github.com/comquent/imperative-when" rel="nofollow noreferrer">imperative-when plugin</a> for scripted Pipelines as described in <a href="https://medium.com/@Lopay/how-to-skip-stages-in-jenkins-scripted-pipeline-f653e54d835d" rel="nofollow noreferrer">this blog post</a> to add visualization (note that I haven't tested this personally).</p>
  <p>Or you can skip the visualization altogether and wrap your build steps in an if clause to conditionally execute them.  You'll see in the Jenkins UI that a stage takes 0ms to execute if it has no steps, so there's at least some indication that it was skipped even if it doesn't explicitly say &quot;skipped&quot;.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-01-29T14:55:02.103Z
Answers: My issue got resolved by importing org.jenkinsci.plugins.pipeline.modeldefinition.*  instead of org.jenkinsci.plugins.pipeline.modeldefinition.Utils
Answers: Aditi Sharma
Answers: CC BY-SA 4.0
Answers: 2021-01-27T01:58:45.503Z
Answers: 2021-01-27T01:58:45.503Z
Answers: jayhendren
Body: <p>I am using a scripted pipeline where I am required to skip some stages conditionally.Is there a way to show skipped stages on Jenkins UI other than importing <strong>org.jenkinsci.plugins.pipeline.modeldefinition.Utils</strong> in the jenkinsfile as the import is giving me &quot;cannot resolve class&quot; error while running build.gradle for some other script.</p>
  
Tags: <jenkins><jenkins-pipeline><jenkins-plugins><jenkinsfile>
Title: Skip stages in Jenkins pipeline
UserDisplayName: Aditi Sharma
ThreadText: # Skip stages in Jenkins pipeline
  
  (Asked by: username_0 on 2021-01-22)
  
  I am using a scripted pipeline where I am required to skip some stages conditionally.Is there a way to show skipped stages on Jenkins UI other than importing **org.jenkinsci.plugins.pipeline.modeldefinition.Utils** in the jenkinsfile as the import is giving me "cannot resolve class" error while running build.gradle for some other script.
  
  **Tags:** jenkins, jenkins-pipeline, jenkins-plugins, jenkinsfile
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-27. Score: 1 | Accepted answer
  
  By default, there is no way to visualize skipped stages in the Jenkins UI. [See this issue report on the Jenkins JIRA about visualizing skipped stages](https://issues.jenkins.io/browse/JENKINS-54322?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel).
  
  There are a few workarounds that I'm aware of:
  
  You can [disable the Groovy sandbox](https://www.jenkins.io/doc/book/managing/script-approval/#groovy-sandbox) to allow importing the aforementioned class.
  
  You can also use the [imperative-when plugin](https://github.com/comquent/imperative-when) for scripted Pipelines as described in [this blog post](https://medium.com/@Lopay/how-to-skip-stages-in-jenkins-scripted-pipeline-f653e54d835d) to add visualization (note that I haven't tested this personally).
  
  Or you can skip the visualization altogether and wrap your build steps in an if clause to conditionally execute them. You'll see in the Jenkins UI that a stage takes 0ms to execute if it has no steps, so there's at least some indication that it was skipped even if it doesn't explicitly say "skipped".
  
  > **Comments:**
  > **username_0**: My issue got resolved by importing org.jenkinsci.plugins.pipeline.modeldefinition.*  instead of org.jenkinsci.plugins.pipeline.modeldefinition.Utils  
  
  ---
  
  