Jenkins Job Builder:将Job放在现有文件夹中

时间:2018-06-15 14:40:37

标签: jenkins jenkins-job-builder

我需要开始使用JJB,但我面临的一个问题是我无法在现有文件夹中上传作业(我&#39 ; m使用Cloudbees文件夹插件)。 我根据SO上现有的问题安排了一个例子:

- project:
name: playground

- job:

    name: sample_job 
    description: 'Automatically generated test'
    project-type: freestyle
    builders: 
      - shell: 'ls'

所以这份工作应该加载到游乐场"夹。 但是语法似乎不正确:

  File "/usr/lib64/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data
    node = self.get_single_node()
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/home/francesco/.local/lib/python2.7/site-packages/jenkins_jobs/local_yaml.py", line 282, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 110, in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
  File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 393, in parse_block_sequence_entry
    "expected <block end>, but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block collection
  in "/home/francesco/git/tests-jobs/jobs/test.yaml", line 1, column 1
expected <block end>, but found '?'
  in "/home/francesco/git/tests-jobs/jobs/test.yaml", line 2, column 1

到目前为止,此问题提供的现有答案与作为JJB一部分创建的文件夹有关。在我的情况下,文件夹已经在前面创建。 有什么帮助吗?

1 个答案:

答案 0 :(得分:1)

@francesco,基本上你必须使用工作,工作模板来创建一个jenkins工作。我已经根据你的问题尝试了这个,并且能够毫无失败地执行。检查这是否回答了你的问题。

---
  - project:
      name: playground
      jobs:
        - sample_job

  - job-template:
      name: sample_job
      description: 'Automatically generated test'
      project-type: freestyle
      builders:
        - shell: 'ls'