0

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

- project:
name: playground

- job:

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

所以应该将作业加载到“playground”文件夹中。但是语法似乎不正确:

  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 的一部分创建的文件夹有关。在我的情况下,该文件夹已经提前创建。有什么帮助吗?

4

1 回答 1

1

@francesco,基本上你必须使用工作,工作模板来创建詹金斯工作。我已经根据您的问题进行了尝试,并且能够顺利执行。检查这是否回答了您的问题。

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

  - job-template:
      name: sample_job
      description: 'Automatically generated test'
      project-type: freestyle
      builders:
        - shell: 'ls'
于 2018-06-17T15:00:14.953 回答