Friday, April 19, 2013

SyntaxHighlighter on Blogger

In my previous post I shared some code with SyntaxHighlighter from Alex Gorbatchev.

This is what I did to integrate it with Blogger.

Log in to Blogger
Click on Design -> Click on Edit HTML Inside the tag, paste in the following:



Copy Code
If you double click inside of the window it will highlight the code, Control-C will copy it to the clipboard.

Use in posts and change brushes
To use the SyntaxHighlighter, edit a post in HTML and put the code inside of these tags:
of pre tags with class="brush: name of brush"

Information of available brushes is here: Available Brushes

Thursday, April 4, 2013

Check for Authorized Jenkins Builds

This is a PowerShell script to prevent an unauthorized user to run a job in Jenkins. I like to use a single script with parameters to deploy code in each environment. But the script could be used by a developer to deploy code from a Jenkins instance in test directly to production.

To get around this, I added code to check the JENKINS_URL environment variable. If a user on a test Jenkins instance tries to deploy to production, the script will immediately stop the deploy.

$env is a reserved variable by PowerShell that imports the JENKINS_URL variable without passing it to the script.

# Check Jenkins URL
$JENKINS_URL = $env:JENKINS_URL
if (($rngenv -eq "prod") -and ($JENKINS_URL -ne "http://jenkinswin.fbfs.com/jenkins")) {
Write-Host "Production deploys must be done from a production Jenkins instance"
Exit}