gvalkov / jenkins-autojobs

Automatically create Jenkins jobs from template jobs and branches in a SCM repository
http://jenkins-autojobs.rtfd.org
Other
49 stars 39 forks source link

Default value for `tag` does not work #18

Open sja opened 10 years ago

sja commented 10 years ago

My configuration contains this:

        # Does not work
        tag: 'myRepoOne'
        refs:
          - 'refs/heads/feature_(.*)'

But that does not use the tag on creating jobs. I had to put a tag on the ref config:

        # Works
        tag: 'myRepoOne'
        refs:
          - 'refs/heads/feature_(.*)'
              'tag': 'myRepoOne'
gvalkov commented 10 years ago

That's strange. One of the tests checks exactly for this and it seems to work:

processing ref: refs/heads/feature/one
. job name: feature-one
. job exists: False
. job created
. config:
  . enable: sticky
  . namesep: -
  . substitute: {'@@JOB_NAME@@': '{shortref}'}
  . re: refs/heads/feature/(.*)
  . tag: group1
  . namefmt: {shortref}
  . template: master-job-1
  . overwrite: True
  . sanitize: {'@!?#&|\\^_$%*': '_'}
Deleted branch feature/one (was 1583e8b).

processing ref: refs/heads/test
. job name: test
. job exists: False
. job created
. config:
  . enable: sticky
  . namesep: -
  . substitute: {'@@JOB_NAME@@': '{shortref}'}
  . re: refs/heads/test
  . tag: group2
  . namefmt: {shortref}
  . template: master-job-1
  . overwrite: True
  . sanitize: {'@!?#&|\\^_$%*': '_'}

Could you run jennkins-autojobs with the -d flag?

arienkock commented 8 years ago

I've had the same issue. The problem for me was that the xpath expression doesn't match anything so there is this trace as a result:

Traceback (most recent call last):
  File "/usr/local/bin/jenkins-makejobs-svn", line 11, in <module>
    sys.exit(_main())
  File "/usr/local/lib/python3.4/site-packages/jenkins_autojobs/svn.py", line 135, in _main
    main.main(argv[1:], config=config, create_job=create_job, list_branches=list_branches)
  File "/usr/local/lib/python3.4/site-packages/jenkins_autojobs/main.py", line 160, in main
    job_name = create_job(branch, tmpl, config, branch_config)
  File "/usr/local/lib/python3.4/site-packages/jenkins_autojobs/svn.py", line 127, in create_job
    tag_method=config['tag-method']
  File "/usr/local/lib/python3.4/site-packages/jenkins_autojobs/job.py", line 92, in create
    self.tag_config(tag, tag_method)
  File "/usr/local/lib/python3.4/site-packages/jenkins_autojobs/job.py", line 72, in tag_config
    desc_el = self.xml.xpath('/project/description')[0]
IndexError: list index out of range

I don't know much about jenkins config.xml format, but with version 1.625.3 I had:

<maven2-moduleset plugin="maven-plugin@2.7.1">
  <actions/>
  <description>Hello</description>
  ...
gvalkov commented 8 years ago

Hello @arienkock,

I believe you've encountered a new issue with jenkins-autojobs. Apparently, it's possible to have a config.xml without a //project/description element. Commit 0619831e4809ba7807b6fea575febdcefacc8b95 should fix this.

As for the original issue, I still can't seem to figure out how it can't work. Running with -d would really help shed some light on the problem. As mentioned, the test_tag_element and test_tag_description tests in tests/test_git.py check exactly for this behavior.

Groetjes, Georgi