Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
groovy::component if语句的计算结果不为true_Groovy - Fatal编程技术网

groovy::component if语句的计算结果不为true

groovy::component if语句的计算结果不为true,groovy,Groovy,您好,我正在试图了解给定的如果(版本存在!=''&&env.force\u build==true)计算为true的问题,即使env.force\u build设置为false pipeline { agent { label 'master' } parameters { string(defaultValue: 'DEV', description: '', name: 'ENV', trim: true) string(defaultVa

您好,我正在试图了解给定的
如果(版本存在!=''&&env.force\u build==true)
计算为true的问题,即使env.force\u build设置为false

pipeline {
    agent { label 'master' }
    parameters {
        string(defaultValue: 'DEV', description: '', name: 'ENV', trim: true)  
        string(defaultValue: 'sys', description: '', name: 'platform_type', trim: true)
        string(defaultValue: 'yyy', description: '', name: 'dev_app_host', trim: true)
        string(defaultValue: 'xxx.dv.local', description: '', name: 'dev_xbar_host', trim: true)
        string(defaultValue: '1.0.0.23', description: '', name: 'VERSION', trim: true)
        booleanParam(defaultValue: false, description: 'force build if possible', name: 'force_build')
    }
    environment {
        git_credential_id = '1234'
        app_name = 'application'
        app_module_name = 'dvmt_event_processor'
        app_git_url = 'ssh://git@oooo:7999/data/application.git'
        dna_common_git_url = 'ssh://git@oooo:7999/data/dna-common.git'
        ansible_git_url = 'ssh://git@oooo:7999/data/operations-ansible.git'
        pip_port = '9700'
    }
    
    stages {
        stage('checkout from SCM') {
            .....
        }
        stage('build') {
                steps {
                    script {
                        // version_exists == dvmt_event_processor-1.0.0.23-py2.py3-none-any.whl
                        // force_build == false

                        def version_exists = ''
                        version_exists = sh(script: "ssh -o StrictHostKeyChecking=no ansible@pypi server ls /var/pypi/packages/dev/ | grep ${env.app_module_name}  | grep ${env.VERSION}" , returnStdout: true)


                        if (version_exists != '' && env.force_build == true) {
                                ......
                                // evaluating to true no matter what
                            }
                        }
                        else if (version_exists != '' && env.force_build == false ) {
                            echo "version already exists, just deploying"
                            ......


                        }
                        else {
                                echo "starting full build"
                                .........
                        }
                    }
                }
            }
        stage('Test') {
            steps {
                echo 'Testing...'
                .............
            }
        }
    }
}
詹金斯控制台o/p

dvmt_event_processor-1.0.0.23-py2.py3-none-any.whl

[Pipeline] echo
false
[Pipeline] echo
starting full build

env.force\u build
像布尔值一样打印,但它是一个字符串

"false" == true
// → false
"false" == false
// → false
始终使用适当的工具调试此类问题。使用
.inspect()
或者甚至
.dump()
要了解您手头的数据类型:

"false".inspect()
// → 'false'
"false".dump()
// → <java.lang.String@5cb1923 value=[102, 97, 108, 115, 101] coder=0 hash=97196323>
"false".toBoolean() == true
// → false
"false".toBoolean() == false
// → true