简体   繁体   English

赛普拉斯采用 Docker 和 Jenkins 流水线。 字符串不匹配模式错误信息

[英]Cypress with Docker and Jenkins pipeline. String does not match pattern error message

I'm doing a cypress 6+ training course and I'm trying to run a Jenkins pipeline using docker.我正在参加 cypress 6+ 培训课程,并且正在尝试使用 docker 运行 Jenkins 管道。 My terminal displayed the following message.我的终端显示以下消息。 I'm trying to figure out how to fix this.我试图弄清楚如何解决这个问题。

{
    "resource": "/Users/xxx/Documents/CypressDocker_JenkinsPipeline/package.json",
    "owner": "_generated_diagnostic_collection_name_#2",
    "severity": 4,
    "message": "String does not match the pattern of \"^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$\".",
    "startLineNumber": 2,
    "startColumn": 11,
    "endLineNumber": 2,
    "endColumn": 26
}

There appeared to be an issue with the package json so I took a look at it. package json 似乎有问题,所以我看了一下。 I honestly can't see what the problem is and would love another pair of eyes to take a look.老实说,我看不出问题出在哪里,我很想用另一双眼睛看一看。

    {
  "name": "CypressDocker_JenkinsPipeline",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "cypress run",
    "headTest": "npm run test -- --headed ",
    "choromeTest": "npm run test -- --browser chrome ",
    "build:and:test": "npm run cy:run start-server-and-test start https://react-redux.realworld.io/ cy:run"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cypress": "^7.1.0"
  },
  "devDependencies": {},
  "description": ""
}

You need to updated the script 'build:and:test', I see issue with launch cypress - the correct command should be您需要更新脚本'build:and:test',我看到启动 cypress 的问题 - 正确的命令应该是

npm run cy:run

Please share the link to course请分享课程链接

Ok, I figured out what went wrong.好的,我知道出了什么问题。 I copied the file from another file and I hadn't created a NEW package.json file.我从另一个文件复制了该文件,但没有创建新的 package.json 文件。 So When I saved the file the package.json was for the original file and did not reflect the changes in the NEW file.因此,当我保存文件时,package.json 用于原始文件,并未反映新文件中的更改。 So cypress was confused as to what was happening.所以赛普拉斯对发生的事情感到困惑。

Then, I created a new package.json file it contained the correct information, I added the commands to run the cypress scripts (headed, Chrome and Docker).然后,我创建了一个新的 package.json 文件,其中包含正确的信息,我添加了运行 cypress 脚本的命令(标题为 Chrome 和 Docker)。 Saved it, restarted VS code and the error went away.保存它,重新启动 VS 代码,错误就消失了。

I also modified Build and test.我还修改了构建和测试。 So the code now reads in the package.json所以代码现在读入 package.json

"build:and:test": "npm run start-server-and-test start https://react-redux.realworld.io/ cy:run"

Just getting it double checked that the command is right.只是让它仔细检查命令是否正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM