首页 > 解决方案 > 两个克隆的 git 存储库与一个 Jenkins 作业一起使用

问题描述

我的詹金斯工作必须从一个 repo 中获取一个 python 脚本,并通过 bash 脚本使用它来对抗另一个 repo,最好的方法是什么?

标签: gitjenkinsjenkins-pluginsclone

解决方案


不知道最好的方法,但这对我有用:

配置 Jenkins 管道以从主存储库中提取 Jenkinsfile 和源。

在 Jenkinsfile 中,根据需要拉取额外的 repos:

dir('{{ repo2 }}') {
    git url: 'ssh://git@{{ githost }}/{{ project }}/{{ repo2 }}.git',
        credentialsId: {{ credId }}
    sh 'source venv/bin/activate && pip install .'
}

(当然,根据需要替换上面的 {{ tokens }}。)

理想情况下,我宁愿设置先决条件作业来构建每个辅助存储库并将其上传到 PyPI 存储库,并让这些要求在主存储库中“正常”得到满足。(练习留给读者。)


推荐阅读