Here is the code. Here I'm using the command "git rev-parse --short HEAD" to get the short hash of the latest GIT commit. But, in order for that to work we need to get into the right directory and CFExecute *starts* in the user directory of whatever user the Coldfusion server is running in. If you haven't set one the it's probably "/root".
So we first need to change directories to the current web root, then we grab the short GIT log hash, like this:
<cfexecute name="/bin/bash" arguments="-c 'cd -P #ExpandPath('/')#; git rev-parse --short HEAD'" variable="variables.test1" timeout="1" />
But a note on the results. If you output the above <cfoutput>[#ariables.test1#]</cfoutput> with brackets around it you will see there is an extra space on the end. That annoys me but I couldn't shake it off. My only solution was to trim itself afterwards with a <cfset variables.test1 = TRIM(variables.test1) />. Lame.
So, why am I wanting the latest short GIT log hash? I'm glad you asked.
<link href="/css/global.css?v=<cfoutput>#server.codeversion#</cfoutput>" type="text/css" rel="stylesheet" />
Yup. I LOVE IT!