Skip to content

Instantly share code, notes, and snippets.

@brokenthumbs
Last active August 29, 2015 13:57
Show Gist options
  • Save brokenthumbs/9901615 to your computer and use it in GitHub Desktop.
Save brokenthumbs/9901615 to your computer and use it in GitHub Desktop.
loggerFile = "logger.log"
warningLog = "puppet_error.log"
channel = manager.build.workspace.channel;
workspace = manager.build.workspace.toString();
result = manager.build.result
checkFile = new hudson.FilePath( channel, workspace + "/" + warningLog )
if ( !checkFile.exists() ) {
return true
}
def initializeFile( file ) {
tmpFile = new hudson.FilePath( channel, workspace + "/" + file )
tmpFile.write( "", null )
}
def appendToFile( data, file ) {
tmpFile = new hudson.FilePath( channel, workspace + "/" + file )
initialData = tmpFile.readToString()
if ( !initialData.isEmpty() ) {
tmpFile.write( initialData + "\n" + data, null )
}
else {
tmpFile.write( data, null )
}
}
def readFromFile( file ) {
return new hudson.FilePath( channel, workspace + "/" + file ).readToString()
}
def appendToLog( data ) {
appendToFile( data, loggerFile )
}
initializeFile( loggerFile )
manager.buildFailure()
manager.addWarningBadge( "Puppet Parser Validation Failure." )
missingFiles = readFromFile( warningLog )
missingFiles = missingFiles.split( "\\\n" )
summary = manager.createSummary( "warning.gif" )
summary.appendText( "<h1>Puppet Parser Validation Failures:</h1><ul>", false, false, false, "red" )
for ( int i = 0; i < missingFiles.size() ; i++ ) {
summary.appendText( "<li>" + missingFiles[i] + "</li>", false )
}
summary.appendText( "</ul>", false )
#!/bin/bash +e
for file in $(find . -iname '*.pp'); do
if [[ $file == *modules/external/* ]]; then
continue
fi
OUTPUT=`puppet parser validate --color false --render-as s --modulepath=modules $file 2>&1`
if [ -n "$OUTPUT" ]; then
echo $OUTPUT
echo $OUTPUT >> puppet_error.log
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment