使用 Jenkins Job Builder 将 Jenkins Job 放入文件夹中

Place a Jenkins Job inside a folder using Jenkins Job Builder

我正在尝试使用 Jenkins Job Builder 在文件夹中创建 Jenkins Job, 到目前为止运气不好 ;(

下面创建作业和文件夹,但作业不在文件夹内;(

请帮忙

其余内容-framework.yaml

- job:
name: folder_test
project-type: folder
primary-view: project_view
health-metrics:
  - worst-child-health-metric

- view:
name: project_view
view-type: list
folder: true
columns:
    - status
    - weather
    - job
    - last-success
    - last-failure
    - last-duration
regex: (?!rest-framework.*).*

- job-template:
name: '{name}-hello-world'
builders:
  - shell: 'echo "hello world!"'

- project:
name: rest-framework
jobs:
  - '{name}-hello-world'

为了将您创建的作业放在文件夹中,请确保项目级别或作业级别的名称包含该文件夹。

示例:

- job-template:
 name: '{name}-hello-world'
builders:
  - shell: 'echo "hello world!"'

- project:
name: folder_test/rest-framework
jobs:
 - '{name}-hello-world'

此代码段需要 已经创建的文件夹(您在上面已经创建了,但为简单起见在此处将其删除)。

已编辑:删除了说这是不可能的原始回复,但我做了更多测试以找到使用 Jenkins-Jobs-Builder 2.0.0 的解决方案。

- job:
    name: 'end2endTestJobs'
    project-type: folder
- job-template:
    name: 'this-is-my-job-name'
    folder: "end2endTestJobs"
- project:
    name: my-project-name
    jobs:
      - this-is-my-job-name

https://jenkins-job-builder.readthedocs.io/en/latest/project_folder.html?highlight=project