Last active
July 3, 2020 09:27
-
-
Save benhodgson87/3a081873dbb33911130cf2e745835724 to your computer and use it in GitHub Desktop.
Jenkins step to run Yarn Audit exiting only on critical level vulnerabilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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