Skip to content

Instantly share code, notes, and snippets.

@wesley-dean
Created November 8, 2021 17:40
Show Gist options
  • Save wesley-dean/8b6cf02d0831b2f6b20586f7da78bfff to your computer and use it in GitHub Desktop.
Save wesley-dean/8b6cf02d0831b2f6b20586f7da78bfff to your computer and use it in GitHub Desktop.
Mega-Linter on Jenkins
{
"extends": "recommended",
"rules": {
"convention.CompileStatic": "off",
"convention.NoDef": "off",
"convention.VariableTypeRequired": "off",
"convention.MethodReturnTypeRequired": "off",
"groovyism.ExplicitCallToEqualsMethod": "off",
"groovyism.GStringExpressionWithinString": "off",
"naming.VariableName": "off",
"naming.FactoryMethodName": "off",
"unnecessary.UnnecessaryGetter": "off",
"size.NestedBlockDepth": {
"maxNestedBlockDepth": 10
},
"unused.UnusedVariable": {
"ignoreVariableNames": "_"
}
}
}
stage('Meta-Linter') {
agent {
docker {
image 'megalinter/megalinter:latest'
args "-e VALIDATE_ALL_CODEBASE=true -v ${WORKSPACE}:/tmp/lint --entrypoint='' GROOVY_NPM_GROOVY_LINT_ARGUMENTS = '--no-insight' DISABLE_LINTERS = 'SPELL_CSPELL'"
reuseNode true
}
}
steps {
sh '/entrypoint.sh'
}
}
@wesley-dean
Copy link
Author

Why is this different from the recommended configuration on the Mega-Linter website?

A few reasons:

  1. the spell checker (CSPELL) was matching on various statements in my code (e.g., ENTRYPOINT in a Dockerfile) and the error reporting was written to a log file in an ephemeral container and that just wasn't helping me
  2. the Groovy linter (npm-groovy-lint) was failing because it was attempting to listen on 0.0.0.0:443 and colliding with another listener; the listener was for the Amplitude insight service which collects anonymous usage statistics and phones home with them; therefore, not for privacy reasons but practical ones, I had to pass --no-insight so that the Groovy linter wouldn't fail)
  3. the Groovy linter was failing my Jenkinsfile examples because it did not include CompileStatic annotations; the included .groovylintrc.json file (from the source) provides a configuration more conducive to linting a Jenkinsfile. If your code actually includes Groovy, the configuration may need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment