2

I'm trying to find a way to pass or "inject" to the build system of Angular for the version and build number to be taken from the user as input for our CI/CD pipeline.

Is there any way to do it without hard-coding the version number in the code/environment .ts files?

3
  • 2
    You can create a separate file under assets. Write the version into that file after the build is completed through jenkins or whichever tool you use. Your code will then refer that file for the version. Commented Dec 15, 2019 at 15:52
  • 1
    You can refer this to insert build number Commented Dec 16, 2019 at 4:20
  • 1
    Thank you guys. until that there will be an official solution, I implemented @AmitChigadani method just because it's the fastest one with minimum changes. you can write it as an answer Commented Dec 16, 2019 at 17:31

1 Answer 1

1

Possible approach without using any environment files:

  1. Create a separate file under assets folder.
  2. Write the new version into that file after the build is completed through Jenkins or whichever tool you use. You can get the build version in Jenkins through its environment variable ${BUILD_NUMBER}

  3. Your code will then refer that file for the version.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.