BuildForge Help

Embedding Build Numbers in Project Files

You can use the .strsub command to swap one string for another in files; a common use is to replace a standard token with a system variable such as the $B variable that provides the current job number.

You can use the .strsub dot command to embed build or version numbers in code files. By placing a .strsub command early in your project, a later step can compile files that contain the updated information.

For example, the following steps set up a project to embed build numbers:
  1. Add a unique string such as _BUILD_ to a file in your project. For example, modify a file README.TXT and change the version declaration as follows:
    Application version 5.0.123
    Application version 5.0._BUILD_
  2. An early step in your project should check out the files to be worked on. Add a step after README.TXT is checked out which replaces _BUILD_ with the $B system variable. For the command, use the following:
    .strsub _BUILD_ $B README.TXT
  3. Run the project and verify that the README.TXT file contains the current job number. For the third run of the project, the README.TXT file should contain this line:
    Application version 5.0.3

Enhancements

You can improve this practice in the following ways:
  • Use additional environment variables. For example, create variables named $MAJORVERSION and $MINORVERSION and use them as follows:
    .strsub _MAJORVERSION_ $MAJORVERSION README.TXT
    .srsub _MINORVERSION_ $MINORVERSION README.TXT
  • Update your environment variables when you start a project. By selecting Jobs > Start to start your projects, you can see the current environment variables and edit their values before you launch the project. You might include a comment in your jobs, for example, as a variable. Use the Project Action Must Change on the comment variable to force users to enter a new value when they run the project.
Related concepts
.strsub