git - 在詹金斯工作中动态选择git repo
问题描述
在 jenkins 工作中,是否可以有多个 git 存储库并根据参数动态选择存储库?
解决方案
您可以在 jenkins 管道中设置 git URL,如下所示:
pipeline {
agent any
parameters {
string(defaultValue: "https://github.com", description: 'Whats the github URL?', name: 'URL')
}
stages {
stage('Checkout Git repository') {
steps {
git branch: 'master', url: "${params.URL}"
}
}
stage('echo') {
steps {
echo "${params.URL}"
}
}
}
}
如果您需要检出多个Git 存储库,也可以根据子文件夹进行设置。
推荐阅读
- javascript - 在javascript中销毁类的实例
- export - 导出要在样式组件中使用的通用调色板
- fortify - 强化扫描:ASP.NET MVC 不良做法:具有必需属性的可选子模型 - 但子模型中的必需属性可以为空
- python - 将 XLSX 转换为 PDF
- reactjs - 为什么这没有在反应时呈现
- r - How to change a group of data values to 0 given the condition
- r - 防止在更改数据时刷新 SelectInput
- java - LiveData 观察者没有通过从 DialogFragment 插入数据来获取数据
- android - 如何获取 Flutter 中导航/状态栏的当前颜色?
- python - 如何在不等待 Tkinter 菜单命令功能完成的情况下更新 Tkinter 标签文本?