与Jenkins CI集成
与 Jenkins CI 的集成是通过墨菲安全的 CLI 工具实现的。墨菲安全 CLI 可以在命令行检测指定目录代码的依赖安全问题。详细了解墨菲安全 CLI 工具
# 安装 CLI
在 Jenkins 机器上安装墨菲安全 CLI
访问 GitHub Releases (opens new window) 页面下载最新版本的墨菲安全 CLI,或执行以下命令:
# 在 Linux 上安装
wget -q https://s.murphysec.com/install.sh -O - | /bin/bash
# 获取访问令牌
注意
CLI 工具需要使用墨菲安全账户的访问令牌
进行认证才能正常使用。访问令牌是什么?(点击查看详情)
进入墨菲安全控制台 (opens new window),点击个人设置
,复制页面中的访问令牌
:
# 设置Jenkins全局凭据
在 Jenkins 全局凭据中添加墨菲安全访问令牌
# 修改Jenkinsfile
为了将墨菲安全 CLI 添加到 pipeline,需要在 Jenkinsfile 中添加一个stage,示例如下:
pipeline {
agent none
stages {
stage('MurphySec Scan') {
environment {
API_TOKEN = credentials('murphysec-token-key')
}
steps {
sh 'murphysec scan . --log-level debug'
}
}
}
}
上次更新: 2022/04/13, 11:54:16