react-native - react native bundle 没有采用 Jenkins 提供的环境变量
问题描述
我有一份 jenkins 工作,负责从 react-native 项目构建 android。管道脚本运行良好,但当它到达时react-native-bundle
它无法告诉我couldn't find environment variable no .env present
。
这是我在詹金斯中使用的脚本
pipeline {
agent any
stages {
stage("Checkout") {
steps {
echo "Environment: ${env.ENVIRONMENT}"
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/pipeline']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'p_rad', url: 'https://***.com/myprj.git']]]
}
}
stage('Dependancies and Bundling') {
steps {
echo 'installing dependancies'
nodejs('NodeJS_7.0.0') {
sh label: '', script: 'npm install -g react-native-cli'
sh label: '', script: 'npm install'
sh label: '', script: 'npm run bundle-android-release'
sh label: '', script: 'cd android'
sh label: '', script: 'chmod +x gradlew'
sh label: '', script: './gradlew clean assembleRelease'
}
}
}
}
}
echo ${env.ENVIRONMENT}
当我从 Jenkins 触发参数化构建时,该命令打印 dev 并且一个参数是 ENVIRONMENT=dev
但是 react-native-bundle 命令无法获取这些值,并且错误表示指定位置下没有 .env 文件。
当我尝试writeFile file: '.env', text: "some parameters=00"
应用程序时(尝试将一个参数写入 .env 文件)
解决方案
推荐阅读
- mongodb - 使用唯一复合索引更新 MongoDB 中的文档
- python - dll加载在python中失败
- webpack - 我收到错误无效的配置对象。Webpack 已使用与 API 模式不匹配的配置对象进行初始化
- docker - 如何在线管理微服务?
- javascript - 确定在自定义菜单中单击了哪个项目
- javascript - 如何将 XML 文件保存为 Java 中 SQL Server 输出的 .xml?
- python - 根据python中的lat long,groupby 2字段计算距离
- c# - 插入 SQL 数据库时的 C# 嵌套 Parallel.ForEach
- c# - 为什么 Windows 服务不调用 OnStart 方法?
- java - 如何从 EpoxyModel 回电?