Modifying the build file
About the build file
The exported build file contains all the settings required
for building and deploying the PBL files of the Example Sales App and some additional
settings:
Build file |
Description | ||||
---|---|---|---|---|---|
|
This section contains the version number of |
||||
|
This section contains settings for source
Both the “SourceControl” and The commands in “PreCommand” and
|
||||
|
This section lists the project(s) that has |
Settings in the build file are independent from each
other; they run in sequence but do not rely on other settings or
execution results, for example, if there is already source code
in ws_objects, then you only need to set the Merging setting,
and leave Git, SVN, and VSS empty as there is no need to
download source code; or if there are PBLs in your Git server,
then you only need to set the Git setting (to download PBLs) and
leave the Merging setting empty. If you do not want a setting to
run, just leave that setting with no values; or add “\” in
front of the setting name, for example, “\Git” or
“\SourceControl”, to skip the setting.
It is recommended that you make a copy of the exported
build file and place it to the same location or a location near
your PowerBuilder application target, so that you could manage
the file path (especially the relative file path) easily.
Note: the relative path specified in the build file is
relative to the build file.
Getting source code from SVN, Git, or VSS
You can configure the exported build file to download
source code from SVN, Git, or VSS before the build process
starts.
Step 1: Make a copy of the exported build file and place
it to a location near your PowerBuilder application target, so
that you could manage the file path (especially the relative
file path) easily.
Note: the relative path will be relative to the build
file.
Step 2: Open the build file in a text editor, locate the
“BuildPlan” section and then configure the corresponding
part.
If the computer connects to Git or SVN through a proxy
server, make sure to configure the proxy server settings in the
“Proxy” part.
The following example shows how to download source code
from Git:
1 2 3 4 5 6 7 8 9 10 |
"BuildPlan": { "SourceControl": { "PreCommand": "", "ClearSrcBeforeDownload": false, "SVN": [ {"SrcPath": "","User": "","Password": "","DestPath": "","Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}} ], "Git": [ <span><strong> </strong></span><span><strong>{"SrcPath": "https://github.com/Appeon/PowerBuilder-AutoBuild-Sales-SourceCode", "User": "tester@appeon.com", "Password": "YGRrYjc6OzU=", "DestPath": ".\Build", "Branch": "", "Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}}</strong></span> ], |
You can also download source code from multiple targets at
one time:
1 2 3 4 |
"Git": [ {"SrcPath": "https://github.com/Appeon/PowerBuilder-AutoBuild-Sales-SourceCode", "User": "tester@appeon.com", "Password": "YGRrYjc6OzU=", "DestPath": ".\Build_Sales", "Branch": "", "Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}}, {"SrcPath": "https://github.com/Appeon/PowerBuilder-AutoBuild-Examples-SourceCode", "User": "tester@appeon.com", "Password": "YGRrYjc6OzU=", "DestPath": ".\Build_Examples", "Branch": "", "Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}} ], |
The following example shows how to download source code
from Team Foundation Server (TFS) or Azure DevOps Server:
IMPORTANT: To download
source code from Team Foundation Server (TFS) or Azure DevOps
Server, you will need to configure the “Git” section, and input
your Personal Access Token (PAT) as the user name and password
for connection.
1 2 3 4 5 6 7 8 9 10 |
"BuildPlan": { "SourceControl": { "PreCommand": "", "ClearSrcBeforeDownload": false, "SVN": [ {"SrcPath": "","User": "","Password": "","DestPath": "","Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}} ], <span><strong>"Git": [ </strong></span> <span><strong>{"SrcPath": "https://402977329@dev.azure.com/402977329/kittytest/_git/kittytest","User": "402977329@qq.com","Password": "ZHFgcXVsZndtY2hicHJkZHxuMXlicXxufjF7OzVzOzB8ejpmcjthZz15eWB5aW0/bDV+eQ==","DestPath": "C:\TFStest\bug1853_1","Branch": "master","Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}} ],</strong></span> |
The following example shows how to download source code
from VSS:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
"BuildPlan": { "SourceControl": { "PreCommand": "", "ClearSrcBeforeDownload": false, "SVN": [ {"SrcPath": "","User": "","Password": "","DestPath": "","Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}} ], "Git": [ {"SrcPath": "","User": "","Password": "","DestPath": "","Branch": "","Proxy": {"Ip": "","Port": 0,"Username": "","Password": ""}} ], "VSS": [ <span><strong> {"SrcPath": "\\192.168.0.100\Project_VSS\"$/Salesdemo/native_pb/appeon.salesdemo", YYOAAAAA","User": "tester","Password": "","DestPath": ".\Build"}</strong></span> ], |
Notes:
1) Connecting to Git or SVN through a proxy server is
supported; but connecting to VSS through a proxy server is not
supported yet.
2) The password for VSS is not supported. The VSS login
window will be displayed for you to input the password before
downloading the source code. The password for SVN or Git must be
an encrypted value which is generated from the original password
by executing “PBAutoBuild220.exe /p”, as shown below.
3) Getting an SVN/VSS branch is completely unsupported.
Getting a Git branch can be supported by using the “Branch”
setting.
Step 3: If the source code downloaded from SVN, Git, or
VSS is not the PBL file but objects in ws_objects, then you will
need to merge the objects to the PBL file. Locate the “Merging”
section in the build file and then configure as below:
Setting “RefreshPbl” to true if you want to refresh the
PBL files by deleting and then generating the PBL files
again.
1 2 3 |
"Merging": [ {"Target": ".\Build\salesdemo.pbt", "LocalProjectPath": ".\Build", "RefreshPbl": false} ], |
You can also merge source code for multiple targets at one
time:
1 2 3 4 |
"Merging": [ {"Target": ".\Build_Sales\salesdemo.pbt", "LocalProjectPath": ".\Build_sales", "RefreshPbl": true}, {"Target": ".\Build_Examples\examples.pbt", "LocalProjectPath": ".\Build_Examples", "RefreshPbl": true} ], |
Merging will not only merge the source code but also
upgrade the source code to the current version. However, it will
not check or upgrade the PBD files used in the library list (you
will need to replace the PBD files with the corresponding
version).
At the same time, make sure to double check the target
location is set correctly in the “Projects” section, for
example,
1 2 3 4 5 6 7 8 |
"BuildJob": { "PreCommand": "", "Projects": [ <span><strong> </strong></span>{"Target": ".\Build_Sales\salesdemo.pbt", "Name": "salesdemo_pbnative"} {"Target": ".\Build_Examples\examples.pbt", "Name": "examplesdemo_pbnative"} ], "PostCommand": "" } |
When the PBAutoBuild220.exe command is executed later, it
will first download the source code from the Git server and then
merge the source code.
Executing additional commands
The entire build process is made up of several steps, and
additional commands can be executed before and/or after some
particular steps such as the “SourceControl” and “BuildJob”
steps.
For example, to add commands to remove a folder before
downloading the source code.
Step 1: Create a bat file which contains the following
command, and save the bat file as Command_DeleteFolder.bat.
1 |
RMDIR /s /q "D:PB2022SalesDemo est" |
Step 2: In the build file, locate the “BuildPlan” section
and then the “PreCommand” sub-section; and add the file path and
name of Command_DeleteFolder.bat.
1 2 3 4 5 6 7 |
"BuildPlan": { "SourceControl": { "PreCommand": <span><strong>"Command_DeleteFolder.bat",</strong></span> "ClearSrcBeforeDownload": false, "SVN": [ ... ], |
When the PBAutoBuild220.exe command is executed
later, it will execute the commands in Command_DeleteFolder.bat before it
downloads the source code.
Besides the “PreCommand” setting, there is also a
“PostCommand” setting for the “SourceControl” and “BuildJob”
steps, which allows you to execute commands after that
particular step. See Example 2 and 3 for more details.
Note
The dotnet commands can
also be integrated with Jenkins. See Task 2 for more
details.