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.
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.
There are a few workarounds that I'm aware of:
You can disable the Groovy sandbox to allow importing the aforementioned class.
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".