OS Call Errors during Jenkins Build

Background

I’m in the process of creating a Jenkins slave node for a Django project that I am currently the Software Integrator for. There is a current build slave for version 1 of the product that runs on Windows 2008 R2 server as a service that logs in with an Active Directory managed service account with no issues. The new build slave is running on Windows 2012 R2 as a service that logs in with an Active Directory group managed service account.

During the build process the Apache httpd service is told to stop/start with Python as follows:
import os
os.system(“httpd -k stop”)

The Error

The build log was showing the error:
‘httpd’ is not recognized as an internal or external command, operable program or batch file.

Why

For some reason the correct environment variable for %PATH% wasn’t being used by Jenkins on the new builder. When running a script to dump %PATH% as the gMSA I get:

C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\7-Zip;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Apache24\bin;C:\ant\bin;C:\Program Files\TortoiseSVN\bin

When running the same script through the Jenkins builder I get the result:

C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\TortoiseSVN\bin

Notice anything missing? C:\Apache24\bin (and C:\ant\bin)

But How’d ya Fix It?

The usual Windows fix didn’t work (aka reboot). I received the same results. After thinking about it for way too long (hey… My background is mostly Microsoft; still a little green in this Open Source stuff…) I remembered that Jenkins can reference variables added to the node during the build.

In Jenkins I selected the problem node and chose ‘Configure’.
Under ‘Node Properties’ I added an Environment variable:
Name = PATH
Value = C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\7-Zip;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Apache24\bin;C:\ant\bin;C:\Program Files\TortoiseSVN\bin

I saved the config and kicked off another build and was excited to find that httpd was now accessible to the build job.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s