Jenkins EnvInject plugin + Pipeline job

后端 未结 3 1627
囚心锁ツ
囚心锁ツ 2021-01-12 15:29

I would like to use EnvInject plugin within my pipeline job. So, I have a possibility to set checkbox \"Prepare an environment for the run\", but there is no action \"Inject

相关标签:
3条回答
  • 2021-01-12 16:08

    If you declared following variables in "Properties Content" block:

    param1=value1
    param2=value2
    

    Then you can get them into pipeline here so:

    //do something
    def par1 = env.param1
    def par2 = env.param2
    
    0 讨论(0)
  • 2021-01-12 16:26

    Pipeline doesn't support it now, please refer to below ticket, and there are some good and alternative ways:

    https://issues.jenkins-ci.org/browse/JENKINS-42614

    0 讨论(0)
  • 2021-01-12 16:28

    Here an example as a complete Jenkins pipeline script:

    pipeline {
        agent any
        stages {
            stage('Test') {
                steps {
                    // use environment variable as parameter to predefined steps
                    echo "These are my parameters: '${env.param}'"
    
                    // use environment variable in a Groovy script block
                    script {
                        def par = env.param
                        println "parameter values: '${par}'"
                    }
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题