Saturday, April 18, 2015

Simultaneous CI on Windows and Linux

In my previous post "CI with SQL*Developer, Jenkins, and GNU make", I demonstrated a working build server using these items:
For my development environment, I use these additional items:
  • Subversion for Source Code Management (SCM)
  • Windows (with Cygwin) for development
  • Linux (Lubuntu) on Amazon for a build server.
Because I use both Windows and Ubuntu, my builds must function on both platforms.  Here are a few tips/tricks I found.

Use SQL*Plus Scripts

SQL*Plus works the same on Windows and Linux.  Maximize use of SQL*Plus scripts.

GNU Tools and POSIX API for Windows

For the scripting that can't be done with SQL*Plus, install GNU Tools and POSIX API on Windows.  I am using Cygwin (  It is not identical to Linux, but is close.  In my previous post I had 2 shell scripts that isolated these differences.

I use the "" script to run the SQL*Developer Command Line Interface.  Here is a portion of it:
# Go to Oracle SQL*Developer binaries
#cd "/opt/sqldeveloper/sqldeveloper/bin"                     # Linux
cd "/cygdrive/c/users/duane/sqldeveloper/sqldeveloper/bin"  # Cygwin
The SQL*Developer Command Line Interface must be run from its installed directory.  This portion of the script resolves the problem that SQL*Developer is installed in different directories on different servers.

Here is another portion of the "" script:
# Run the SQL*Developer Command Line Interface
#./sdcli "${@}"           # Linux
cmd /C sdcli "${@}"      # Cygwin
The SQL*Developer Command Line Interface requires a Windows command shell to properly run in Windows.  Since Cygwin is running a "bash" shell, the Windows command shell must be called in Windows.  This script is not checked into SCM because it must be configured for each server.

The above script ( runs the SQL*Developer Command Line from its installation directory.  It passes all command line parameters to sdcli (using "${0}").  However, there is a problem.  Since the script executes from a different directory, any parameter with a file name needs to include a path back to the current directory.  That where this script ( helps.  This script returns the current directory as a full path.  However, it also makes an adjustment for Cygwin.
if pwd -P | grep -q '^/[Cc][Yy][Gg][Dd][Rr][Ii][Vv][Ee]/'
   pwd -P | sed -e 's#^/[Cc][Yy][Gg][Dd][Rr][Ii][Vv][Ee]/##1' \
                -e 's#/#:/#1'
   pwd -P
The adjustment made for Cygwin is based on the idea that full paths to disk files in Cygwin start with "/cygdrive/".  This script checks for that string at the beginning of the full path.  If it finds the strings, it substitutes the correct drive letter at the front of the path.  Remember, this is in preparation for running "sdcli".  "sdcli" must have Windows paths, not Linux paths.  This script can be checked into SCM because it works for both Cygwin and Linux.

Everything else listed in these posts should run on Windows and Linux without problem.  Cheers!

No comments:

Post a Comment