代码之家  ›  专栏  ›  技术社区  ›  Pritish

如何定制Jenkins pipeline舞台视图?

  •  0
  • Pritish  · 技术社区  · 2 年前

    我想定制詹金斯管道舞台。
    在下面的截图中,我不想要这些步骤 Approve K8s Dev Deployment Create and Deploy to k8s Dev Environment 在pipeline stage视图中显示,因为我基于分支名称跳过了这些。下面是电流输出。

    enter image description here

    我希望管道阶段的观点是看到像下面这样没有 批准K8s开发人员部署 创建并部署到k8s开发环境 .我希望我的预期产出如下。我是否遗漏了任何插件?我怎样才能做到这一点?

    enter image description here

    下面是我的groovy代码:

    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}")
                }
            }
        }
    }
    
    0 回复  |  直到 2 年前