I want to declare map variable in my constants.groovy for different kinds of environments:
- TEST
- PRE-PROD
- PROD
and for each one I want to have its own URL and Jenkins user credential. In the pipeline itself there will be a choice parameter where user will have to choose kind of environment. Once build started, the pipeline will know how to pull the URL and Cred for the user choice. any idea how it can be done? As a start I think This can help
UPDATE
I got the answer for my question, but adding one on top of it:
How I can do map inside map here? assuming user chose TEST, I want it to have 3 types of server: SQL, SSIS, SSRS.
Is this the right code for it:
Map myMap = [
TEST:[SQL_URL:'', SSIS_URL: '', SSRS_URL: ''], credential,
PREPROD:[SQL_URL:'', SSIS_URL: '', SSRS_URL: ''], credential,
PROD:[SQL_URL:'', SSIS_URL: '', SSRS_URL: ''], credential
] as ConfigObject
def props = myMap.toProperties()
props [ env.environment_type ].SQL_URL
props [ env.environment_type ].SSIS_URL
props [ env.environment_type ].credential