Tutorial 7: Building your PowerServer project with commands

Besides building and deploying your PowerServer project in the PowerBuilder IDE, you can also build and deploy your PowerServer project with commands (PBAutoBuild210.exe).

Beta limitations

The PBAutoBuild210.exe tool has the following limitations or unsupported features in the beta version:

  1. Relative paths are not supported consistently in the beta version, therefore, it is recommended to use absolute paths. Relative paths will be fully supported in the GA version.

  2. The PBAutoBuild210.exe tool will report the unsupported features in the log file in the beta version. It will report the unsupported features in the specified file in the GA version.

  3. The PBAutoBuild210.exe tool does not support publishing the PowerServer Web APIs to the hosting server (such as Kestrel, IIS, Docker etc.).

  4. VSS is not supported in the beta version. It will be supported in the GA version.

  5. SVN and Git are supported in the beta version, however, the proxy settings for SVN and Git do not support username and password in the beta version.

Task 1: Preparing the environment

Install the following software on the same machine:

  • Windows 10 (64-bit)

  • PowerBuilder IDE 2021

  • PowerBuilder Runtime 2021

  • PowerBuilder Compiler 2021

  • PowerServer Toolkit 2021

Task 2: Exporting the build file

This tutorial will assume that you have already followed the Quick Start guide to

  1. create a PowerServer project for the Example Sales Demo;

  2. build and deploy the PowerServer project (using the Build & Deploy PowerServer Project option in the PowerBuilder IDE) successfully; and

  3. run the installable cloud app successfully.

Now let's export the PowerServer project settings of the Example Sales Demo to a JSON file:

Step 1: Open the workspace for the Example Sales App in the PowerBuilder IDE, and then double-click the PowerServer project object to open the PowerServer project painter.

If no PowerServer project object is available, please follow the Quick Start guide to create one.

Step 2: When the PowerServer project painter is opened, click the Export PowerServer Build File button () in the toolbar.

Step 3: In the Export Build File dialog box, write down the path and filename to be exported, and then click Export.

Task 3 (Optional): Configuring the build file

The exported build file contains all the settings required for building and deploying the PBL files of the Example Sales App. It also contains some advanced settings that allow you to perform the following:

  • Getting and merging source code from SVN or Git;

  • Executing additional commands during the build process.

Getting source code from SVN or Git

You can configure the exported build file to download source code from SVN or Git before the build process starts.

Step 1: Open the exported build file in a text editor, locate the "BuildPlan" section and then the "Git" sub-section, and configure the "Git" sub-section as shown below.

    "BuildPlan": {
        "SourceControl": {
            "PreCommand": "",
            "SVN": [
                {"SrcPath": "","User": "","Password": "","DestPath": "","Proxy": {"Ip": "","Port": 0}}
            "Git": [
                {"SrcPath": "https://github.com/appeonguojun/SalesDemo_Git", "User": "tester@appeon.com", "Password": "YGRrYjc6OzU=", 
                 "DestPath": "D:\\Support\\PB2021\\GIT\\Sales_Demo\\Build", "Proxy": {"Ip": "","Port": 0}}

Note: The password must be an encrypted value which is generated from the original password by executing "PBAutoBuild210.exe /p", as shown below.

Step 2: If the source code downloaded from SVN or Git 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 exported build file and then configure as below:

            "Merging": [
                {"Target": "D:\\Support\\PB2021\\GIT\\Sales_Demo\\Build\\salesdemo.pbt", "LocalProjectPath": "D:\\Support\\PB2021\\GIT\\Sales_Demo\\Build"}

At the same time, make sure to double check the target location is set correctly in the "Projects" section, for example,

        "BuildJob": {
            "PreCommand": "",
            "Projects": [
                {"Target": "D:\\Support\\PB2021\\GIT\\Sales_Demo\\Build\\salesdemo.pbt", "Name": "ps_salesdemo"}
            "PostCommand1": ""

When the PBAutoBuild210.exe command is executed later, it will first download the source code from the Git server and then merge the source code, as shown below.

Executing additional commands

The entire build & deploy 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 the "build" 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.

RMDIR /s /q "D:\Support\PB2021\GIT\Sales_Demo\Build"

Step 2: In the exported build file, locate the "BuildPlan" section and then the "PreCommand" sub-section; and add the file path and name of Command_DeleteFolder.bat.

    "BuildPlan": {
        "SourceControl": {
            "PreCommand": "D:\\Support\\PB2021\\GIT\\Sales_Demo\\Command_DeleteFolder.bat",
            "SVN": [
                {"SrcPath": "","User": "","Password": "","DestPath": "","Proxy": {"Ip": "","Port": 0}}

When the PBAutoBuild210.exe command is executed later, it will execute the commands in Command_DeleteFolder.bat before it downloads the source code.

Besides the "PreCommand" sub-section, there is also a "PostCommand" sub-section for the "SourceControl" and "BuildJob" steps, which allows you to execute commands after that particular step.

Task 4: Running the PBAutoBuild210.exe command

The PBAutoBuild210.exe file is by default located under the PowerBuilder Compiler 2021 installation folder (for example, %AppeonInstallPath%\PowerBuilderCompiler [version]\PBAutoBuild210.exe).

Step 1: In the command line window, execute the PBAutoBuild210.exe file and the export build file. For example,

PBAutoBuild210.exe /f "D:\Support\PB2021\GIT\Sales_Demo\ps_salesdemo.json" /l "D:\Support\PB2021\GIT\Sales_Demo\Log_PSBuild.log" /le "D:\Support\PB2021\GIT\Sales_Demo\Log_PSError.log"

Step 2: Carefully check the information in the command line window to make sure the build and deploy process is successful.

The build files and commands used in this tutorial can be downloaded from https://github.com/appeonguojun/AutoBuild_SalesDemo. After you download these files to D:\Support\PB2021\GIT\Sales_Demo\, you can directly run AutoBuild_PowerServer.bat.

Task 5: Integrating with Jenkins

The PBAutoBuild210 command can integrate with Jenkins to automate the build and deployment process for PowerServer projects. Refer to the Jenkins user documentations for how to use Jenkins.

Following gives a few examples on how to integrate the PBAutoBuild210 command with Jenkins.

For example, to execute the PBAutoBuild210 command and the exported build file.

For example, to download source code from SVN or Git, and then execute the PBAutoBuild210 command and the exported build file. (Double check that the PBT location is the same one in all required areas.)