Friday, December 01, 2017

Revisiting Continuous Integration with PowerBuilder 2017, Bonobo Git and Jenkins

In a previous blog post I ran through a example of how to use the new command line compiler feature of PowerBuilder 2017 to perform continuous integration using Jenkins and a Git repository.  One of the "next steps" I referenced in the close of that post was the creation of a plug-in for Jenkins that would make creating the build steps for the project much simpler.

Well, I've created such a plugin.  Or more specifically what I did was take the existing MSBuild plugin and customize it to do PowerBuilder compiles instead.

In this post I'm going to look at how we can use that plugin, plus some additional changes I've made to the project in Jenkins to make better use of the capability of Jenkins and other Jenkin plugins.

Download and install the PBCompile plugin

The first thing you'll need to do is grab a copy of the pbcompile plugin.  What you'll need is the PBCOMPILE.HPI. file.

Go into Jenkins and select the "Manage Jenkins" option, and then the "Manage Plugins" link on that page.

On the Plugin Manager page select "Advanced" and then look for the "Upload Plugin" section. Click the "Browse" button there and navigate to the HPI file you downloaded.

You'll need to restart the Jenkins server after installing the plugin before you can use it.

Configure the PBCompile plugin installation

After the server has been restarted go back into "Manage Jenkins" and then "Global Tool Configuration".

Scroll down that page and you'll see a new "PBCompile" section.  Select the "PBCompile installations..." button

The only two items you'll need to provide are a name for the installation and the directory where the orcascript170 and pbc170 files are at.

Create a new PBCompile build step

Go back into your PowerBuilder project and select the "Configure" link.

Delete all the previous build steps.  Now add a new one and notice a new "Build a PowerBuilder target using PBC" option has been added.  Select that one.

You'll now see a build step that is custom to PowerBuilder 2017.

  • PBCompile Version: Select the name you defined in the "PBCompile installations" above.  It should be the only available entry.
  • PBT File:  Provide PBT file for your project, including any relative directory path.
  • Exclude Liblist:  Optional,  It only needs to be populated if there are PBD files in the library.  That tells OrcaScript to take those as are rather than attempting to generate them.
  • PBC Command Line Arguments:  The data you pulled from the project painter in PowerBuilder that previously we put in the batch file.

  • Pass build variables as properties:  The checkbox currently isn't used.  MSBuild has this feature, and the option was left in here just in case a later version of the PowerBuilder Autocompile utility adds similar capability.
The plugin provides the same capability as the first two batch files from the previous blog article, namely running OrcaScript to create PBLs from source control and then running the AutoCompile Utility (PBC170.exe) to create the executables and PBD from the PBLs.

Archive the Project Artifacts

What we're going to do now is replace the third batch file, the one that copies the EXE and PBDs into the build folder.  Jenkins has some built in capabilities that make this simpler that I didn't demonstrate in the previous article.

The first thing we're going to do is to tell Jenkins to archive off the EXE and PBDs (Jenkins calls them "artifacts").  To do this, create a Post Build step and select "Archive the Artifacts"

In the new step that is added, enter the following in for the "Files to Archive".

       **/*exe, **/*.pbd

The syntax is Apache Ant include fileset.  This particular setting tells Jenkins to find all of the EXE and PBD files in the workspace - including in any subdirectories - and copy them into the archive location.  When it does so it preserves the subdirectory structure, something we'll deal with in the next step.

Install the Copy Artifacts plugin

Now that we have the PBDs and EXE in the archive location, we want to use the Copy Artifacts Plugin to copy them to the build folder.  First we'll need to install the plugin.  Go back to the Manage Jenkins  -> Manage Plugins page, but this time select the "Available" tab.  Because there are a lot of plugins for Jenkins you might want to use the Filter option in the upper right to pear down the list.

Once again you'll need to restart the server before you can use the plugin.

Create a Copy Artifacts project

After the server has been restarted, create a new project.  We'll fire this project off after the build is complete from our original PowerBuilder project.  You might simply name the new project as the original project name with an " - Output" suffix, as I've done here.

The only thing we're going to do with this new project is create one build step.  Do that, and choose the new "Copy artifacts from another project" option.

  • Project to Copy From:  Select your original PowerBuilder project.
  • Artifacts to Copy:  You can leave this blank, as it defaults to copying all artifacts.
  • Target Directory:  The he location you want the files copied to, and can reference the Jenkins environmental variables using $VARIABLENAME (as opposed to %VARIABLENAME% that we used in the batch files).  For example, I'm using:


    In the previous article I was concatenating the job_name and build_number for the directory.  I like this better as I'm now putting the builds in subdirectories under the job name.
  • Flatten Directories:  The one other option you will want to change is to check the "Flatten Directories" option.  That tells the plugin to just copy over the EXE and PBD files and ignore the subdirectory structure.

Great a Post Build step to fire the Copy Artifacts project

Go back into the original PowerBuilder project.  We need to add another Post Build step. This time select "Build other projects".

And in the new post build step specify your "output" project as the project to run after the PowerBuilder project completes.

Test the new configuration

Run a build of your PowerBuilder project just to verify that it's all working.  You'll notice some differences.  In particular, the build information now shows the artifacts that were created and the "output" project as a "Downstream Project".

The build information from the "output" project isn't particularly interesting, but we can check out build folder and see that the build files are being created and stored correctly.

No comments: