Search code examples
azure-devopsazure-pipelinesazure-pipelines-release-pipelinerelease-management

Best practices to manage and deploy artifacts for different environments (dev, test, prod etc...)


I'm new to the CI/CD world and now I would like to implement these workflows in my development process.
I would like to understand how properly make a build and release pipeline to manage Dev, Test and Prod environments when Dev, Test and Prod have slight differences.

So I'm making an Asp .Net Core app, the code is hosted in Azure DevOps which I will use also for build and release, for the client side code (js and css) I use Typescript and SASS and to compile to js and css I use npm scripts.

Now in the Dev environment I want to deploy the non minified js and css and I want also the sourcemap files, in Test environment instead I want the minified js and css and the sourcemap files, in the prod environment I want only the minified version of my css and js.

This case is taken only as practical example, but I would like to understand the general rule, which I can apply regardless of the kind of app or the host, build and release platforms.
As an additional note I understand that this case is pretty trivial and could be managed pretty easily without too much ceremonies, but I would like to understand the guidelines and the best practices, and then I will chose what is appropriate to my particular case and adapt those guidelines and best practices accordingly.

Now I can chose between different options:

  1. I can manage the differencies at the build stage:
    1. I can have one build pipeline which produce the "standard" client code, the source map and the minified versions and deploy the same artifacts to Dev, Test and Prod;
    2. I can have different build pipeline for different environment;
    3. I can have one build pipeline and use conditional tasks;

  2. I can manage the differences at the release stage:
    1. I can build the code using the option 1.1 and then exclude the files that I don't need in the release pipeline;
    2. I can build only the server side code in the build pipeline and compile the client side code during the release pipeline;
    3. I can compile the standard version of the js and css files in the build pipeline and in the release pipelines I can produce the source map or i can minify the js and css;

I don't like the option 1.1 because I don't like to have useless files spread all over the place and this add some extra steps in the build pipeline that aren't necessary.

The options 1.2 and 1.3 adds some complexity to the build pipelines.

With the options 2.x we have "incomplete" builds, because the artifacts produced by the build process lacks of some artifacts that are required by the deploy environment.

To me, which I don't know what are the guidelines and the best practices for the CI and CD workflows, seem that the much more appropriate is one of the option 1.3 or 2.3.

If I'm not wrong now the question become:
It is acceptable to have build pipelines that produces artifacts which are not entirely shippable because they don't meet the requirements for the deploy environment (like the needs to have the sourcemap in Dev environment)?


Solution

  • Ciao Leoni,

    I've been a release manager for a number of years, and I understand your pain. In the system I worked on the sequence was something like this: 1: from the development domain to a staging server 2: from the staging server to a penetration & vulnerability testing environment 3: from the testing domain to SaaS production domain and DML repository. 4: from production domain to an escrow and installed cut.

    My recommendation is that all tidying up, such as removal of developer's back-up routines (named following an strict convention) and minification is done on the staging server. We allowed minor bug fixes to be applied to the staging server code, and then 'fix pack' releases cut. Once the code is in the penetration & vulnerability testing environment, our practice was that the code itself must not change: only the security settings between domains and for escrow/installed release.

    Once a documented process is agreed to, it's easy for people to use that as a check sheet. Your processes may need to be different from what I've out-lined above, and they should be expected to be refined over time. I know many people who do not like documented procedures, but I've documented some benefits here: http://www.esm.solutions/wp/change-management/

    A presto, Robert