Jenkins Job Builder:将作业放在现有文件夹中
Jenkins Job Builder: place Job in an existing folder
我需要开始使用 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 的一部分创建的文件夹有关。在我的例子中,该文件夹已经提前创建。
有帮助吗?
@francesco,基本上你必须使用工作,工作模板来创建 jenkins 工作。我已经根据您的问题进行了尝试,并且能够无故障地执行。检查这是否回答了您的问题。
---
- project:
name: playground
jobs:
- sample_job
- job-template:
name: sample_job
description: 'Automatically generated test'
project-type: freestyle
builders:
- shell: 'ls'
我需要开始使用 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 的一部分创建的文件夹有关。在我的例子中,该文件夹已经提前创建。 有帮助吗?
@francesco,基本上你必须使用工作,工作模板来创建 jenkins 工作。我已经根据您的问题进行了尝试,并且能够无故障地执行。检查这是否回答了您的问题。
---
- project:
name: playground
jobs:
- sample_job
- job-template:
name: sample_job
description: 'Automatically generated test'
project-type: freestyle
builders:
- shell: 'ls'