在 groovy 中创建命名步骤
Creating a Named step in groovy
我正在努力学习 groovy 我的管道设置,但我被困在一些非常基础的东西上,但我不知道从哪里开始寻找解决我的问题的方法。
我想做的基本上是创建一个包含多个命名步骤的阶段。下面我发布了一个我正在尝试做的基本示例,'go to way' 会是什么。(这只是创建一个文件夹,里面有一个压缩文件)。
旁注:此代码目前抛出错误
WorkflowScript: 23: Expecting "interface jenkins.tasks.SimpleBuildStep" but got Mkdir
pipeline {
agent any
stages {
stage('Zipfile'){
steps{
step('Mkdir'){
sh 'mkdir LocalDir'
}
step('Touch File'){
sh '''cd LocalDir
touch File
cd ..'''
}
step('Zip'){
sh '''cd LocalDir
zip File.zip File
cd ..'''
}
}
}
}
}
我想我不得不让你失望了。你不能命名 step
。 official documentation没有提到这样的事情。
来自官方文档:
steps
The steps section defines a series of one or more steps to be
executed in a given stage directive.
Required: Yes
Parameters: None
Allowed: Inside each stage block.
我想我找到了问题的预期......我应该添加带有步骤的命名阶段
pipeline {
agent any
stages {
stage('Zipfile'){
stages{
stage('mkdir'){
steps{
sh 'mkdir LocalDir'
}
}
stage('Touch File'){
steps{
sh '''cd LocalDir
touch File
cd ..'''
}
}
stage('Zip'){
steps{
sh '''cd LocalDir
zip File.zip File
cd ..'''
}
}
}
}
}
}
我正在努力学习 groovy 我的管道设置,但我被困在一些非常基础的东西上,但我不知道从哪里开始寻找解决我的问题的方法。
我想做的基本上是创建一个包含多个命名步骤的阶段。下面我发布了一个我正在尝试做的基本示例,'go to way' 会是什么。(这只是创建一个文件夹,里面有一个压缩文件)。
旁注:此代码目前抛出错误
WorkflowScript: 23: Expecting "interface jenkins.tasks.SimpleBuildStep" but got Mkdir
pipeline {
agent any
stages {
stage('Zipfile'){
steps{
step('Mkdir'){
sh 'mkdir LocalDir'
}
step('Touch File'){
sh '''cd LocalDir
touch File
cd ..'''
}
step('Zip'){
sh '''cd LocalDir
zip File.zip File
cd ..'''
}
}
}
}
}
我想我不得不让你失望了。你不能命名 step
。 official documentation没有提到这样的事情。
来自官方文档:
steps
The steps section defines a series of one or more steps to be executed in a given stage directive.
Required: Yes
Parameters: None
Allowed: Inside each stage block.
我想我找到了问题的预期......我应该添加带有步骤的命名阶段
pipeline {
agent any
stages {
stage('Zipfile'){
stages{
stage('mkdir'){
steps{
sh 'mkdir LocalDir'
}
}
stage('Touch File'){
steps{
sh '''cd LocalDir
touch File
cd ..'''
}
}
stage('Zip'){
steps{
sh '''cd LocalDir
zip File.zip File
cd ..'''
}
}
}
}
}
}