Skip to content

Instantly share code, notes, and snippets.

@benhodgson87

benhodgson87/Jenkinsfile

Last active Jul 3, 2020
Embed
What would you like to do?
Jenkins step to run Yarn Audit exiting only on critical level vulnerabilities
// Run yarn audit and only exit 0 on critical vulnerabilities (greater than 8)
// https://github.com/yarnpkg/yarn/blob/298e0ea6cea3ab8a610cabf28de3fdf8e7fa8d1f/src/cli/commands/audit.js#L158-L162
//
// Credit: https://github.com/yarnpkg/yarn/issues/7260#issuecomment-506556626
stage('Node dependencies') {
steps {
sh script: '/bin/bash -c "yarn audit; [[ $? -ge 8 ]] && exit 1 || exit 0"', label: "Vulnerability audit"
sh script: 'yarn', label: 'Install dependencies'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.