drno-reg
@drno-reg
см не кратко

Как в декларативном pipeline Jenkins динамически сменить имя stage?

Решили мы попробовать уйти от Scripted Pipeline в сторону Declarative Pipeline
и столкнулись с вопросом как динамически переопределить название stage?

def template1 = "spread_sshkeys"

pipeline {
    agent any

    stages {
        stage ("Checkout") {
            steps {
                deleteDir()
                checkout scm
                sh "git submodule foreach --recursive git pull origin master"
            }
        }
        stage('test') {
            steps {
                    script {
                        sh "ls -las; cd jenkins-ci-examples; ls -las";
                    }
            }
        }
        stage('run template ${template1}') {
            steps {
                sh "ls -las; cd jenkins-ci-examples; ls -las";
            }
        }

    }
}


как в scripted
stage('run template ${template1}')
не работает теперь

Есть ли вообще такая возможность?
  • Вопрос задан
  • 77 просмотров
Решения вопроса 1
drno-reg
@drno-reg Автор вопроса
см не кратко
ответ на вопрос есть здесь

https://stackoverflow.com/questions/68136020/how-m...

если кратко то необходимо написать как-то так

def template1 ="spread_sshkeys"
pipeline {
    agent any

    stages {
        stage('Dynamic Stages') {
            
            steps {
                script {
                        stage("import template ${template1}"){
                            println("${env.STAGE_NAME}")
                        }
                         stage("run template ${template1}"){
                            println("${env.STAGE_NAME}")
                        }
                }
            }
        }
        
    }
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы