Home > OS >  is possiable write variable '${properties.${params.deployed_region)_env_region}' in Jenkin
is possiable write variable '${properties.${params.deployed_region)_env_region}' in Jenkin

Time:11-19

Hello am getting loading variable from propeties file in jenkins pipeline am defing varibles in properties file

Mumbai_env_region: ap-south-1
N.virginia_env_region: us-east-1

here mumbai is choice parameters

parameters {
        choice(
            name: 'deployed_region',
            choices: ['Mumbai', 'N.virginia', 'Singapore'],
            description: 'Note: user can opt for deployment environment'
        )
    }

i want be execute sh script like this

echo '${properties.${params.deployed_region)_env_region}'

but am geeting _env_region Such No propery error

but am geeting _env_region Such No propery error

CodePudding user response:

Without using the dot notation try the following.

def propValue = properties["${params.deployed_region}_env_region"]

CodePudding user response:

stages {
       stage ('Prepare properties ') {
          steps {
            script {
              properties = readProperties file: "jenkinfiles/aws-properties/${params.deployed_region}.properties"
              def propValue = "properties[${params.deployed_region}_env_region]"

              }
            }
          }

if use this it gives no properties error

  • Related