Search code examples
javascriptnode.jsazure-pipelinespipelinebitbucket-pipelines

What is the Correct Flow for a JavaScript Application Pipeline with Buildtime Variables?


Consider the following development flow for a frontend JavaScript application:

Development Flow

Whilst there are endless ways to design a development->staging->production pipeline, the above is fairly standard right?

Given this, why is it that pipeline providers such as Bitbucket and Azure do not allow Environment dependant variables for the build step?

Like most JavaScript applications, our application is specifically built for the environment that it will be run in e.g. development, staging, and production. Each environment has their own uniquely defined set of variables, for example; APP_URL sets the URL that the application will be accessible under.

The environment variables are specifically read during the build process of the application i.e. they are buildtime variables, not runtime variables.

Is there a reason why these providers do not support different environment variables for the build step? This seems like such an obvious thing which makes me think that actually, our entire pipeline flow is incorrect and it is us that is doing this wrong... Can any suggest a way to overcome this issue? Ideally without setting these variables within the xyz-pipelines.yml as the whole purpose of these variables is to keep them out of the repository...


Solution

  • In DevOps, it is expected you get an artifact in Build pipeline and then release that artifact into environments using a Release workflow.

    You could try to build the frontend JavaScript application in the Release pipeline, in Release pipeline, which can get artifacts from continuous integration systems such as Azure Pipelines, Jenkins, or TeamCity. You might also use version control systems such as Git or TFVC to store your artifacts. More details, please refer to the following link:

    https://learn.microsoft.com/en-us/azure/devops/pipelines/release/artifacts?view=azure-devops#sources