Reputation: 4328
I'd need to get started with JJB however one issue I'm facing is that I'm not able to upload jobs in an existing Folder (I'm using Cloudbees Folder plugin). I've arranged an example based on an existing question available on SO:
- project:
name: playground
- job:
name: sample_job
description: 'Automatically generated test'
project-type: freestyle
builders:
- shell: 'ls'
So the job should be loaded into the "playground" folder. However the syntax seems uncorrect:
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
The existing answers provided so far on this question are related to folders created as part of JJB. In my case the folder has been already created ahead. Any help ?
Upvotes: 0
Views: 737
Reputation: 1274
@francesco, Basically you have to use jobs, job template to create a jenkins job. I have tried this based on your question and able to execute without failures. Check if this answers your question.
---
- project:
name: playground
jobs:
- sample_job
- job-template:
name: sample_job
description: 'Automatically generated test'
project-type: freestyle
builders:
- shell: 'ls'
Upvotes: 1