Is it possible for Azure DevOps to update part of my code when release kicks in?
For example, I have a setting file inside my react app. This setting file has export const ISPROD = false
in it. I need Azure DevOps to change this false value to true before it builds the react app and deploys it. Is that possible?
Note: My Server build is Linux.
You could update your code in your javascript files using the "Replace Tokens" task e.g.
- task: replacetokens@3
inputs:
targetFiles: "yourJavascriptFile.js"
encoding: "auto"
writeBOM: true
verbosity: "detailed"
actionOnMissing: "warn"
keepToken: false
tokenPrefix: "#{"
tokenSuffix: "}#"
displayName: Perform variable substitution in javascript file file
You'd add this task before the task you use to build your application.
In your javascript file you would write the variables to be replaced as e.g.
export const ISPROD = #{IS_PROD}#
This task when run would then replace "#{IS_PROD}#" with your Azure Devops variable named "IS_PROD" with it's value set as true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With