Solved: Lowercase var Using TeamCity Mac Build Agent Command Line Step

June 4, 2018

Nerd

I had a heck of a time figuring this out, so I’m blogging it :)

branch=`echo "%teamcity.build.branch%"| tr '[:upper:]' '[:lower:]'`

(Note the back ticks around the entire value – they’re important =)

While I”m here, I’ll also blog how to set a TC param from within the same script & use a case statement with default fallthrough :)

case $branch in 
  'master'|'refs/heads/master'|*release/*|*hotfix/*) 
    echo "Stable Version"
    echo "##teamcity[setParameter name='MyTeamCityParam' value='stable']"
    ;;
  *)
    echo "Alpha Version"
    echo "##teamcity[setParameter name='MyTeamCityParam' value='alpha']"
    ;;
esac

(The 1st echo statements in the case statements are just for TC build log metadata for me)

No comments yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: