在Jenkins管道中使用cypress代理 [英] Using cypress behind proxy in Jenkins pipeline

查看:68
本文介绍了在Jenkins管道中使用cypress代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在github上看到了这一点,但是我仍然无法获得 cypress 来正确配置/下载.在我的詹金斯管道中,我运行 npm install ,但是由于代理的原因,这会导致超时.它将下载 cypress 所需的所有其他依赖项.

I have seen this on github but I was still not able to get cypress to configure/download correctly. In my jenkins pipeline I run npm install but this runs into a timeout because of the proxy. It downloads all other dependencies expect cypress.

我所做的是下载 cypress 并将zip文件放入项目中.然后,我运行 sh"setCYPRESS_INSTALL_BINARY = cypress.zip npm i cypress" ,但这仍然失败.

What I did was download cypress and put the zip file in the project. I then run sh "setCYPRESS_INSTALL_BINARY=cypress.zip npm i cypress" but this still fails.

在Jenkins管道中失败的部分:

Part that fails in Jenkins pipeline:

   sh "npm config set proxy http://<proxy>"
   sh "npm config set registry http://<proxy>/"
   sh "setCYPRESS_INSTALL_BINARY=cypress.zip npm i cypress"
   sh "npm i"
   sh "npm run build 

如何在不下载cypress的情况下运行 npm i .我目前无法通过此行 sh"setCYPRESS_INSTALL_BINARY = cypress.zip npm i cypress" ,但我也担心 npm i setCYPRESS_INSTALL_BINARY之后仍会尝试下载cypress实际有效

How can I have npm i run without download cypress. I currently cannot get passed this line sh "setCYPRESS_INSTALL_BINARY=cypress.zip npm i cypress" but I am also concerned npm i will still try to download cypress after setCYPRESS_INSTALL_BINARY actually works

-------------------------更新One -----------------

-------------------------Update One-----------------

我更新了 Jenkinsfile ,使其具有 CYPRESS_INSTALL_BINARY = cypress.zip npm i ,但现在出现以下错误. Cypress.zip 现在在项目中,但真的希望将其上传到Jenkins并仅引用我的Jenkinsfile中的文件路径.

I updated the Jenkinsfile to have CYPRESS_INSTALL_BINARY=cypress.zip npm i but now I get the below error. Cypress.zip is in the project now but would really like to have it uploaded to Jenkins and just reference the file path within my Jenkinsfile.

我不确定这是否可行,最简单的解决方案是我正在考虑的解决方案,但是它失败了.

I am not sure that is possible and the most simple solution is the one I am doing I think however it fails.

新错误:

[view] Running shell script

+ CYPRESS_INSTALL_BINARY=cypress.zip

+ npm install

npm WARN locking Error: EIO: i/o error, open '/home/jenkins/.npm/_locks/staging-c21b8f081f002623.lock'

npm WARN locking  /home/jenkins/.npm/_locks/staging-c21b8f081f002623.lock failed { Error: EIO: i/o error, open '/home/jenkins/.npm/_locks/staging-c21b8f081f002623.lock'

npm WARN locking   stack: 'Error: EIO: i/o error, open \'/home/jenkins/.npm/_locks/staging-c21b8f081f002623.lock\'',

npm WARN locking   errno: -5,

npm WARN locking   code: 'EIO',

npm WARN locking   syscall: 'open',

npm WARN locking   path: '/home/jenkins/.npm/_locks/staging-c21b8f081f002623.lock' }

npm ERR! path /home/jenkins/.npm/_locks/staging-c21b8f081f002623.lock

npm ERR! code EIO

npm ERR! errno -5

npm ERR! syscall open

npm ERR! EIO: i/o error, open '/home/jenkins/.npm/_locks/staging-c21b8f081f002623.lock'

script returned exit code 251

推荐答案

在Windows环境中,我遇到了类似的问题.我将cypress.zip放入项目的根文件夹中.

I had similar issues on Windows environment. I placed cypress.zip into project's root folder.

set CYPRESS_INSTALL_BINARY=cypress.zip
echo %CYPRESS_INSTALL_BINARY%
npm install cypress --save-dev

因此安装不起作用,因为npm可执行文件在<您的项目文件夹> \ node_modules \ cypress \

So installation did not work, because npm executable looks for cypress in <your project folder>\node_modules\cypress\

尝试将CYPRESS_INSTALL_BINARY设置为绝对路径.

这篇关于在Jenkins管道中使用cypress代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆