【问题标题】:How to discover Jenkinsfile in subfolders如何在子文件夹中发现 Jenkinsfile
【发布时间】:2017-10-12 08:45:00
【问题描述】:

我的项目有两个独立的文件夹,需要在 Jenkins 中单独构建(运行 v2.74)

我的结构是

folder
├── project1
│   └── Jenkinsfile
└── project2
    └── Jenkinsfile

当我在 Jenkins 中单击“扫描组织”时,它没有发现子目录中的 Jenkinsfiles。

以下是“扫描组织日志”中的一个示例:

Proposing kg-pipeline
Examining my-test-project

  Checking branches...

  Getting remote branches...

    Checking branch jenkins
      ‘Jenkinsfile’ not found
    Does not meet criteria

    Checking branch master
      ‘Jenkinsfile’ not found
    Does not meet criteria

  2 branches were processed

Finished examining my-test-project

我没有触及扫描组织并使用 Jenkinsfiles 查找分支的作业的配置。这是项目的当前设置

我的问题是:如何配置 Jenkins 以单独查看每个文件夹?我也对以这种方式设置的示例项目的链接感兴趣。

【问题讨论】:

    标签: jenkins-pipeline multi-project


    【解决方案1】:

    有一个简单的解决方案。

    1. 转到 JENKINS_URL/job/JOB_NAME/configure
    2. Build Configuration 下,为Mode 选择by Jenkinsfile
    3. Script Path下,设置为DIR_NAME/Jenkinsfile

    例如,如果您将 Jenkinsfile 放在 src 目录中,那么您可以将其设置为 src/Jenkinsfile,Jenkins 现在就可以找到该 Jenkinsfile

    【讨论】:

      【解决方案2】:

      目前正在尝试设置相同的东西 - 这可能会有所帮助,即使它不是一个完整的答案:

      根据this,您应该能够设置两个多分支管道项目,每个项目的配置模式为“by Jenkinsfile”。

      JENKINS-34561 中添加了对 Jeninsfile 使用自定义路径的支持

      【讨论】:

        【解决方案3】:

        您可以在项目识别器下添加多个“管道 Jenkinsfile”以及 Jenkins 文件的路径。

        【讨论】:

        • 您能否添加更多详细信息来解释这如何回答问题?
        • 在一个组织文件夹中,当您扫描多个存储库时 - 不同的存储库可能在不同的位置有 Jenkinsfile。使用多个项目识别器可以解决这个问题,以便您能够在组织中具有不同结构的所有存储库中进行扫描。但是,如果您希望从同一个 repo 加载多个 jenkins 文件,很遗憾,这不能在一个组织文件夹设置中完成
        • Multiple Jenkinsfile per repository 仍在探索中:issues.jenkins-ci.org/browse/…
        猜你喜欢
        • 1970-01-01
        • 2012-04-19
        • 1970-01-01
        • 2016-01-30
        • 2014-08-22
        • 1970-01-01
        • 1970-01-01
        • 2016-10-07
        • 1970-01-01
        相关资源
        最近更新 更多