【发布时间】:2019-01-08 00:00:25
【问题描述】:
我有以下 Jenkinsfile,我认为它设置正确。我以https://jenkins.io/doc/book/pipeline/syntax/#sequential-stages 为例,但由于某种原因,当我在收到的詹金斯中运行它时,
WorkflowScript:11:未知的阶段部分“阶段”。从...开始 0.5版本,阶段中的步骤必须在步骤块中
谁能告诉我我错过了什么或做错了什么?
pipeline {
agent {label 'windows'}
stages {
stage('Quick Build') {
steps {
echo 'Building'
}
}
stage('Deploy to Dev') {
// when {
// branch 'develop'
// }
stages {
stage('Building Distributable Package') {
steps {
echo 'Building'
}
}
stage('Archiving Package') {
steps {
echo 'Archiving Aritfacts'
archiveArtifacts artifacts: '/*.zip', fingerprint: true
}
}
stage('Deploying Dev') {
steps {
echo 'Deploying'
timeout(time:3, unit:'DAYS') {
input message: "Approve build?"
}
}
}
}
}
stage('Deploy to Test') {
when {
branch 'develop'
}
steps {
echo 'deploying..'
timeout(time:3, unit:'DAYS') {
input message: "Approve build?"
}
}
}
stage('Deploy to Prod') {
when {
branch 'release'
}
steps {
timeout(time:3, unit:'DAYS') {
input message: "Deploy to Prod?"
}
echo 'Deploying....'
}
}
}
}
提前致谢!
【问题讨论】:
-
您的脚本看起来不错。我还通过在 Jenkins v2.121.1 中运行来验证它
-
我在 2.107.3,我会升级看看是否能解决我的错误。
-
尝试了
when语法之一,它对我有用stackoverflow.com/questions/37690920/…