在jenkins中运行时如何忽略实际的dotenv(.env)文件 [英] How can I ignore the actual dotenv (.env) file while running in jenkins

查看:208
本文介绍了在jenkins中运行时如何忽略实际的dotenv(.env)文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在赛普拉斯中,如何在jenkins中运行时忽略dotenv(.env)文件,因为jenkins在实际的环境变量上运行.现在我得到No such file or directory open/student-proj/.env 我如何检查它是否在jenkins中运行,然后使用实际的env变量,否则使用.env ?

In cypress how can I ignore the dotenv (.env) file while running in jenkins, as jenkins run on actual environment variables. Now I am getting No such file or directory open/student-proj/.env How can I check if it is running in jenkins then use actual env variables else use .env ?

plugins/index.js

const configEnv = require('dotenv').config();
const cucumber = require('cypress-cucumber-preprocessor').default;

module.exports = (on, config) => {
  on('file:preprocessor', cucumber());

  if (configEnv.error) {
    throw configEnv.error;
  }
  const env = { ...config.env, ...configEnv.parsed };
  
  const envData = { ...config, env };
  return envData;

}

推荐答案

为什么不只在代码中使用特定的jenkins env变量,例如JOB_NAME ...如果该值返回null ...,则表示该值未在jenkins上运行

why not just use a jenkins env variable specific in your code e.g. JOB_NAME ... if the value returns null... that means its not running on jenkins

这篇关于在jenkins中运行时如何忽略实际的dotenv(.env)文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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