1

I have Jenkinsfile (Pipeline script) in root of Master branch.

Code has below stages: 1) checkout 2) Build-test 3) Archive artifact 4) Deploy

We deploy to QA and PROD env from master branch and both environments have different configuration and right now we have single Jenkinsfile.

I need suggestion what is the best approach for deployment ? 1. Should i create folder and sub-folder and keep respective Jenkinsfile 2. Use some environment variables that can be passed on run-time for respective environment

Any other idea .. please help me with your suggestions i want to make pipeline script reusable ,

Manoj Bhagwat
  • 151
  • 2
  • 14

1 Answers1

1

I recommend using the same Jenkinsfile to deploy to both environments. This will reduce gaps between the two environments, and also minimize unexpected errors and behaviors when promoting features from QA to PROD.

Ideally, you should provide the different configs for each environment as "parameters" to the deployment. Configurations can be many and putting them in the jenkins ui as parameters won't be a good idea.

The best way to do this is to maintain the environment configurations under some source code management such as Git. That way the configuration will be properly version and maintained.

The deployment job will then require as parameter a location to this configuration, the job should then fetch this configuration and use it to deploy on the specific environment

yamenk
  • 46,736
  • 10
  • 93
  • 87