相关疑难解决方法(0)

如何在shell脚本中声明和使用布尔变量?

我尝试使用以下语法在shell脚本中声明一个布尔变量:

variable=$false

variable=$true
Run Code Online (Sandbox Code Playgroud)

它是否正确?另外,如果我想更新该变量,我会使用相同的语法吗?最后,使用布尔变量作为正确的表达式是以下语法:

if [ $variable ]

if [ !$variable ]
Run Code Online (Sandbox Code Playgroud)

bash shell scripting boolean sh

884
推荐指数
14
解决办法
84万
查看次数

java.lang.NoSuchMethodError: 在步骤中找不到这样的 DSL 方法“$”

我有以下 dsl

pipeline {
    agent {
        label 'test'
    }
    parameters {        
        booleanParam(defaultValue: false, description: 'This is a Release build', name: 'isRelease')
    }

    stages {
        stage('Build') {
            steps {
                 script {
                     if (${params.isRelease}) {
                          echo("This is a release")
                     }
                 }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这失败并出现以下错误

java.lang.NoSuchMethodError: No such DSL method '$' found among steps 
Run Code Online (Sandbox Code Playgroud)

我做错了什么?我在用

  • 詹金斯 2.89.4
  • 工作 DSL 1.68
  • 流水线作业 2.20
  • 管道:API 2.27
  • 管道:基本步骤 2.7
  • 管道:构建步骤 2.7
  • 管道:声明性 1.2.9

jenkins

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

bash ×1

boolean ×1

jenkins ×1

scripting ×1

sh ×1

shell ×1