Project

Profile

Help

Task #8505

Update jjg scripts to use results of https://dev.osll.ru/issues/7996 for distributing jobs among views

Added by Mark Zaslavskiy about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
High
Assignee:
Timofey Turenko
Category:
jenkins_jobs
Sprint/Milestone:
Start date:
17.07.2017
Due date:
% Done:

100%

Estimated time:
3:00 h
Target branch:
Test scenario:

https://github.com/OSLL/jjg/tree/8505_distributing_jobs_among_views

https://github.com/OSLL/jjg/pull/4

For testing:
1. Create empty job: 8505_test_job
2. Fill it:
- job:
name: 8505_test_job
description: 'View: regular_test. This job doing something'
3. In descriprion must be specified view, or nothing will be happen.
4. Update job on max-tst-01:
./scripts/ud_job.sh ./test_configs/jekins.ini update 8505_test_job.yaml
5. In console output you will see:
SUCCESS: job - '8505_test_job' has been added to view - 'regular_test'
6. Look at:
http://127.0.0.1:8089/view/regular_test/
Or else view, where you added job.

You will get error if write wrong view, like this:
ERROR: No view named 1233sad inside view Jenkins
ERROR: job - '8505_test_job' adding to view '1233sad' failed!
But job will be successfully updated on server, without notify the view.

If you dont write view, or use only whitespaces (like a: "View: . ", you dont get any errors and only update job.

WARNING: if you get 403 error, download actual jenkins-cli.jar and place in $HOME path.
wget http://127.0.0.1:8089/jnlpJars/jenkins-cli.jar
Your Java version should be same (like a Java8 on server and your local).


Description

Update jjg scripts to use results of https://dev.osll.ru/issues/7996 for distributing jobs among views.
Now every job has it's view in description. JJG shoud add job to jenkins. Then JJG shoul parse job's description and get job's view. Then using jenkins cli JJG should add job to parsed view.

History

#1 Updated by Alexander Kaluzhny about 4 years ago

  • Status changed from New to Active / In progress

#2 Updated by Alexander Kaluzhny about 4 years ago

  • Status changed from Active / In progress to New

#3 Updated by Alexander Kaluzhny about 4 years ago

  • Status changed from New to Active / In progress

#4 Updated by Alexander Kaluzhny about 4 years ago

  • Status changed from Active / In progress to New

#5 Updated by Alexander Kaluzhny about 4 years ago

  • Description updated (diff)
  • Assignee deleted (Alexander Kaluzhny)

#6 Updated by Mark Zaslavskiy about 4 years ago

  • Assignee set to Ilfat Kinyaev

#7 Updated by Ilfat Kinyaev about 4 years ago

Test on maxscale-jenkins, results should be: job in view.

#8 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from New to Active / In progress

#9 Updated by Ilfat Kinyaev about 4 years ago

  • Estimated time set to 3:00 h

#10 Updated by Ilfat Kinyaev about 4 years ago

  • % Done changed from 0 to 100
  • Test scenario updated (diff)

#11 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from Active / In progress to Review
  • Assignee changed from Ilfat Kinyaev to Mark Zaslavskiy

#12 Updated by Mark Zaslavskiy about 4 years ago

1. Please add ability to create view in case it does not exist.

2. When i launch

vood@vood-ThinkPad:~/ws/jjg$ ./scripts/ud_job.sh ../maxscale-jenkins-jobs/jenkins.ini.template update ../maxscale-jenkins-jobs/8505_test_job
Timestamp: 2017-08-09 12:58:16+03:00, Git ID: 1c38a57d49b8711ee791499d07efbcac2011e87d
PATH: ../maxscale-jenkins-jobs/8505_test_job, GIT BRANCH:  8505_distributing_jobs_among_views
[2017-08-09 12:58:16+03:00 ID=1c38a57d49b8711ee791499d07efbcac2011e87d GITBRANCH= 8505_distributing_jobs_among_views PATH=../maxscale-jenkins-jobs/8505_test_job]
description modified
INFO:jenkins_jobs.cli.subcommand.update:Updating jobs in ['../maxscale-jenkins-jobs/8505_test_job_temp'] ([])
INFO:jenkins_jobs.builder:Number of jobs generated:  1
INFO:jenkins_jobs.builder:Reconfiguring jenkins job 8505_test_job
INFO:jenkins_jobs.cli.subcommand.update:Number of jobs updated: 1
INFO:jenkins_jobs.builder:Number of views generated:  0
INFO:jenkins_jobs.cli.subcommand.update:Number of views updated: 0
java.net.ConnectException: В соединении отказано
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at hudson.cli.CLI.connectViaCliPort(CLI.java:205)
    at hudson.cli.CLI.<init>(CLI.java:129)
    at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
    at hudson.cli.CLI._main(CLI.java:474)
    at hudson.cli.CLI.main(CLI.java:385)
    Suppressed: java.io.IOException: Server returned HTTP response code: 403 for URL: http://127.0.0.1:8089/cli
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
        at hudson.cli.FullDuplexHttpStream.<init>(FullDuplexHttpStream.java:78)
        at hudson.cli.CLI.connectViaHttp(CLI.java:153)
        at hudson.cli.CLI.<init>(CLI.java:133)
        ... 3 more
ERROR: job - '' adding to view 'regular_test' failed!
- job: 
    name: 8505_test_job 
    description: 'View: regular_test. This job doing something 
[2017-08-09 12:58:16+03:00 ID=1c38a57d49b8711ee791499d07efbcac2011e87d GITBRANCH= 8505_distributing_jobs_among_views PATH=../maxscale-jenkins-jobs/8505_test_job]

#13 Updated by Mark Zaslavskiy about 4 years ago

  • Status changed from Review to New
  • Assignee changed from Mark Zaslavskiy to Ilfat Kinyaev

#14 Updated by Ilfat Kinyaev about 4 years ago

  • Test scenario updated (diff)

#15 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from New to Review
  • Assignee changed from Ilfat Kinyaev to Mark Zaslavskiy
  • Test scenario updated (diff)

#16 Updated by Mark Zaslavskiy about 4 years ago

  • Status changed from Review to New
  • Assignee changed from Mark Zaslavskiy to Ilfat Kinyaev

when job and view does not exist, only view is created:

vagrant@maxscale-jenkins:~/mdbci_kinyaev/jjg$ ./scripts/ud_job.sh ./test_configs/jenkins.ini.template update 8505_test_job.yaml 
Timestamp: 2017-08-16 10:42:40+02:00, Git ID: 639386ed02269acce05a1c1154170ed88b8fc440
PATH: 8505_test_job.yaml, GIT BRANCH:  8505_distributing_jobs_among_views
[2017-08-16 10:42:40+02:00 ID=639386ed02269acce05a1c1154170ed88b8fc440 GITBRANCH= 8505_distributing_jobs_among_views PATH=8505_test_job.yaml]
description added
INFO:jenkins_jobs.cli.subcommand.update:Updating jobs in ['8505_test_job.yaml_temp'] ([])
Traceback (most recent call last):
  File "/usr/local/bin/jenkins-jobs", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/cli/entry.py", line 145, in main
    jjb.execute()
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/cli/entry.py", line 139, in execute
    ext.obj.execute(self.options, self.jjb_config)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/cli/subcommand/update.py", line 105, in execute
    options, jjb_config)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/cli/subcommand/update.py", line 82, in _generate_xmljobs
    parser.load_files(options.path)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/parser.py", line 132, in load_files
    self.parse(in_file)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/parser.py", line 167, in parse
    self._parse_fp(fp)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/parser.py", line 136, in _parse_fp
    data = local_yaml.load(utils.wrap_stream(fp), search_path=self.path)
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/local_yaml.py", line 444, in load
    return yaml.load(stream, functools.partial(LocalLoader, **kwargs))
  File "/usr/local/lib/python2.7/dist-packages/yaml/__init__.py", line 71, in load
    return loader.get_single_data()
  File "/usr/local/lib/python2.7/dist-packages/yaml/constructor.py", line 37, in get_single_data
    node = self.get_single_node()
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/local/lib/python2.7/dist-packages/jenkins_jobs/local_yaml.py", line 212, in compose_document
    node = self.compose_node(None, None)
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 110, in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
  File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/local/lib/python2.7/dist-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/vagrant/mdbci_kinyaev/jjg/8505_test_job.yaml_temp", line 1, column 1
expected <block end>, but found '?'
  in "/home/vagrant/mdbci_kinyaev/jjg/8505_test_job.yaml_temp", line 2, column 1
SUCCESS: view - '8505_test_view' has been created
!!JOB_NAME=8505_test_job

ERROR: No such job '8505_test_job'; perhaps you meant 'run_test'?
ERROR: job - '8505_test_job' adding to view '8505_test_view' failed!
- job:
name: 8505_test_job
    description:  '[2017-08-16 10:42:40+02:00 ID=639386ed02269acce05a1c1154170ed88b8fc440 GITBRANCH= 8505_distributing_jobs_among_views PATH=8505_test_job.yaml]
'
description: 'View: 8505_test_view. This job doing something' 

#17 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from New to Review
  • Assignee changed from Ilfat Kinyaev to Mark Zaslavskiy

Error occures if yaml job file is not well-formed

#18 Updated by Mark Zaslavskiy about 4 years ago

  • Status changed from Review to Testing
  • Assignee changed from Mark Zaslavskiy to Timofey Turenko

#19 Updated by Timofey Turenko about 4 years ago

  • Status changed from Testing to Closed

Also available in: Atom PDF