I want to customize the Jenkins pipeline stage.
In the below screenshot, I don't want the steps Approve K8s Dev Deployment and Create and Deploy to k8s Dev Environment to show in the pipeline stage view as I am skipping these based on my branch names. Below is the current output.
I want the pipeline stage view to be seen something like below without the Approve K8s Dev Deployment and Create and Deploy to k8s Dev Environment. I want my expected output as below. Am I missing out any plugins? How can I achieve this?
Below is my groovy code:
stages{
stage('Checkout') {
steps{
checkout scm
}
}
// Maven Build and Unit Tests Dev
stage('Build and Unit Tests') {
steps{
build(configuration)
}
}
// SonarQube Analysis
stage('SonarQube analysis') {
steps{
sonarQubeGating(configuration)
}
}
// Build Docker Image and Push to Artifactory
stage('Build Docker Image and Push to Artifactory') {
steps{
artifactoryImagePush(configuration)
}
}
// Approve DEV Deployment
stage('Approve K8s Dev Deployment') {
when {
anyOf {
expression {
return (env.GIT_BRANCH.startsWith('master') || env.GIT_BRANCH.startsWith('hotfix-'))
}
}
}
steps {
approveDeployment()
}
}
// Create and Deploy to Dev Environment
stage('Create and Deploy to k8s Dev Environment') {
when {
anyOf {
expression {
return (env.GIT_BRANCH.startsWith('master') || env.GIT_BRANCH.startsWith('hotfix-'))
}
}
}
steps {
withCredentials([string(credentialsId: "$env.K8S_DEV_NS_TOKEN", variable: 'DEV_TOKEN')]) {
kubernetesDeploy(hcEnv: 'dev', hcToken: "${DEV_TOKEN}")
}
}
}
}

