我正在尝试获取 Cypress Dashboard 中的提交信息详细信息。我还没有能够完成,但我已经取得了一些进步......
我将描述到目前为止我所做的事情:
- 安装了commit-info通过运行以下命令进行 npm 包:
npm install --save @cypress/commit-info
- 在
plugin/index.js
文件中导入插件,如下所示:
const { commitInfo } = require('@cypress/commit-info');
module.exports = on => {
on('file:preprocessor', file => {
commitInfo().then(console.log);
});
};
现在我在终端中获取了所有信息,作者、分支、提交和消息!:) 但是,我仍然没有链接到我的 Cypress 仪表板的详细信息。
这是我目前得到的:
接下来的步骤是什么?我不清楚该文档...
最佳答案
在我们的例子中,我们在 docker 容器内运行所有内容。我们将代码复制到容器中,但不复制 .git 目录,它很大,耗时,而且我们不需要它。 @cypress/commit-info
assumes there is a .git directory ,所以既然没有,它就不起作用。
我们通过设置 the values cypress expects 克服了这个问题在我们的 Jenkinsfile 中的 cypress run 命令中明确显示:
def commitMessage = sh(script:"git log --format=%B -n 1 ${env.GIT_COMMIT}", returnStdout:true).trim()
def commitAuthor = sh(script:"git log --format='%an' -n 1 ${env.GIT_COMMIT}", returnStdout:true).trim()
def commitEmail = sh(script:"git log --format='%ae' -n 1 ${env.GIT_COMMIT}", returnStdout:true).trim()
def cypressVars = "COMMIT_INFO_BRANCH=${env.GIT_BRANCH} COMMIT_INFO_SHA=${env.GIT_COMMIT} COMMIT_INFO_REMOTE=${env.GIT_URL} COMMIT_INFO_MESSAGE=\"${commitMessage}\" COMMIT_INFO_AUTHOR=\"${commitAuthor}\" COMMIT_INFO_EMAIL=${commitEmail}"
// call cypress however you do and include cypressVars as part of the command
关于javascript - 如何使用 Jenkins 在 CI 中的 Cypress 仪表板中填充作者、分支、提交、消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60818764/