2

I am pretty new to Jenkins and its plugins. I managed to setup a declarative pipeline job on my Jenkins server. The pipeline stage view is a bit strange.

  1. There is a gap between the first stage and the left-hand side panel.

  2. There are extra stages as Declarative Checkout SCM, Declarative Agent Setup and Declarative Post Actions being displayed, which are not part of my Jenkinsfile. Can I hide these stages and only show stages in my Jenkinsfile?

Here is the version info of my configuration:

pipeline-stage-view                Pipeline: Stage View Plugin       2.10
pipeline-stage-step                Pipeline: Stage Step              2.3
pipeline-stage-tags-metadata       Pipeline: Stage Tags Metadata     1.3.7
simple-theme                                                         0.5.1
jenkins version 2.164.1

I also use the neo2 theme via the simple-theme plugin

enter image description here

Update 1 Disabling the simple-theme plugin made NO difference

Frank Liu
  • 1,466
  • 3
  • 23
  • 36

1 Answers1

1

I figured out the source of these extra steps and how to get rid of them by change your Jenkinsfile.

Originally my Jenkinsfile looks like

  pipeline {
    agent { dockerfile true } // causes the "Declarative Agent Setup" stage

    options {
        ansiColor('xterm')
    }

    stages {
       ...
    }
    post { // causes the "Declarative Post Actions" stage
       ...
    }
}

The Declarative Checkout SCM is the default behaviour when you configure your pipeline to use Pipeline script from SCM.

After I updated my Jenkins file to

  pipeline {
    agent { label 'docker' } // Not using dockerfile directly to prepare the agent 

    options {
        ansiColor('xterm')
        skipDefaultCheckout() // removes the "Declarative Checkout SCM" stage
    }

    stages {
       stage ('Checkout') {
          checkout scm
       }
    }
    post { // causes the "Declarative Post Actions" stage
       ...
    }
}

I managed to get rid of Declarative Agent Setup and Declarative Checkout SCM

Still no idea about how to fix the Gap

Frank Liu
  • 1,466
  • 3
  • 23
  • 36
  • Since you are consuming `post {}` method, there is no way around it, the stage is implicitly invoked by Jenkins libraries. It is better to go for custom stages as it allows more control, however, can you explain the benefit of using `post{}` ? Please refer https://stackoverflow.com/questions/57623209/jenkins-declarative-pipelines-how-to-rename-declarative-post-actions-step – mdabdullah Jul 07 '21 at 20:26