jenkins - 在 jenkins 中从 shell 脚本设置环境变量
问题描述
我正在尝试使用Jenkins
. 我的构建过程需要执行三个不同的shell scripts
. 第一个脚本设置了第二个和第三个脚本使用的一些。 environment variables
我正在尝试pipeline
在 Jenkins 中的一份工作,其中每个脚本都是分阶段执行的。但是我无法从第一个脚本获取环境变量到下一个脚本。
注意:正在设置一组变量。所以我不觉得使用简单的变量就可以了。
请帮忙
解决方案
您可能将声明性管道与脚本化管道混淆了
Jenkinsfile(声明式管道)
pipeline {
agent any
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
sh 'printenv'
}
}
}
}
Jenkinsfile(脚本流水线)
node {
withEnv(['DISABLE_AUTH=true',
'DB_ENGINE=sqlite']) {
stage('Build') {
sh 'printenv'
}
}
}
推荐阅读
- julia - 当 C++ (LLVM) 可以时,为什么 Julia 不优化此代码?
- django-views - for 循环已执行,但未显示学校列表
- javascript - JS fetch 下载文件:在哪里放置微调器?
- html - 如何使用 bettersoup 从此给定代码中提取 href 链接。我已经尝试过堆栈溢出的其他结果
- elasticsearch - Elasticsearch 跨集群搜索启用
- tensorflow - 如何解决 Tensorflow.js 转换器错误?
- php - React:创建输入的函数
- theorem-proving - 如何执行所有共享一个多元普遍量化假设的多个存在消除?
- php - 为什么 PHP 脚本在调试时有时会在 index.php 开头重新启动?
- java - 如何为同一个属性节点添加多个约束违规?