jenkins - Jenkins Pipeline - 从远程 git url 读取属性
问题描述
我有一个位于 git 项目中的属性文件。在构建一个单独的项目时,我想读取这个属性文件来提取一些常见的配置。
readProperties 只允许从当前工作区加载文件。
如何从管道中的不同 git 项目中读取属性文件。
解决方案
您可以克隆 repo/只下载属性文件:
node() {
stage("Clone repo") {
git url: "https://github.com/ozlevka/go-envinronment.git"
//fileDownloadOperation url: "https://raw.githubusercontent.com/ozlevka/go-envinronment/master/bbb.properties"
}
stage("Read properies")
{
def props = readProperties file: './bbb.properties'
for (def key in props.keySet())
{
println "key = ${key}, value = ${props[key]}"
}
}
}
推荐阅读
- android - 使用 Retrofit 和 moshi -Android 解析 Json 失败
- r - \\n 是什么意思以及如何删除它?
- c++ - 如何判断#define 是否有值
- elasticsearch - 带有必须和应该的 Elasticsearch 术语查询
- angular - 根据文化信息动态配置Angular中的数字格式
- javascript - 反应 localStorage 对象属性返回未定义
- python - ValueError:int() 的无效文字,基数为 10:终端中的“favicon.ico”
- mysql - 3张表来计算商品价格
- laravel - 在 Laravel 8 中使用 Tailwind 安装 Font Awesome
- node.js - 如何在猫鼬中填充另一个模型的子文档?