Vim syntax highlighter?

24 views
Skip to first unread message

Aleksey Tsalolikhin

unread,
Jun 4, 2021, 10:26:30 PM6/4/21
to jenkins-job-builder
Hello,

Does anyone have a Vim syntax highlighter for JJB?

I couldn't find one...

Would anyone else like one?  :)

Best,
Aleksey

Andrew Grimberg

unread,
Jun 5, 2021, 10:51:52 AM6/5/21
to Aleksey Tsalolikhin, jenkins-job-builder
Nothing specific to JJB. I just use the basic yaml syntax that comes
with vim. Along with also having syntastic [0] setup as a plugin to
help. There isn't much oustide of standard yaml happening in JJB for me
to really think that a custom highlighter would be needed.

-Andy-

[0] git://github.com/scrooloose/syntastic.git

--
Andrew J Grimberg
Manager Release Engineering
The Linux Foundation
OpenPGP_0x3360FFB703A9DA1F_and_old_rev.asc
OpenPGP_signature

Aleksey Tsalolikhin

unread,
Jun 5, 2021, 2:35:41 PM6/5/21
to Andrew Grimberg, jenkins-job-builder
Thanks, Andy!

I am new to JJB and have been struggling with differentiating JJB elements from variables.


```yaml
- project:
    name: test_custom_distri
    disabled: true
    distributions: !!python/tuple [precise, jessie]
    architectures: !!python/tuple &architectures
      - amd64
      - i386
    axis_a:
        type: user-defined
        name: architectures
        values: *architectures
    jobs:
      - '{name}-source'

- job-template:
      name: '{name}-source'
      project-type: matrix
      disabled: '{obj:disabled}'
      axes:
        - axis:
            type: user-defined
            name: distribution
            values: '{obj:distributions}'
        - axis: '{obj:axis_a}'
```

I can't tell by looking at that code if "distributions" is a JJB syntax element (like "name" and "disabled") or a variable.

I am getting to know the JJB syntax elements, but it would be nice to have a visual cue.  :)

Best,
Aleksey
--
Aleksey Tsalolikhin
DevOps - Sr. Systems Engineer | Team Golf - Scrum Master and Developer
 LinkedIn  •   Instagram  •   Youtube

Thanh Ha

unread,
Jun 6, 2021, 11:05:49 AM6/6/21
to Aleksey Tsalolikhin, Andrew Grimberg, jenkins-job-builder
Hi Aleksey,

"distribution" is a variable because it's defined as a required input in the job-template per the "values: '{obj:distributions}'" line. The "obj:" prefix is syntax to say the variable should be sent in as the object that it originally defined in he project, in this case a tuple.

An easy way to tell if something is a variable is by the curly braces {var} surrounding the variable name in the job-template.

Hope this helps,
Thanh

--
You received this message because you are subscribed to the Google Groups "jenkins-job-builder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins-job-bui...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkins-job-builder/CAGG6SKSo8yAy4C5P80udJfGPWHxDxeGHV8Su-tzvSfz%3DJhDCmQ%40mail.gmail.com.

Aleksey Tsalolikhin

unread,
Jun 7, 2021, 12:30:01 PM6/7/21
to Thanh Ha, Andrew Grimberg, jenkins-job-builder
Thanks, Thanh!  That's really helpful of you, I appreciate it!

When I'm looking at the project file (where the variable is set), there is no indication of whether it's a JJB built-in or a user-defined variable - is there? 

Thanks again!
Aleksey

Thanh Ha

unread,
Jun 7, 2021, 5:31:31 PM6/7/21
to Aleksey Tsalolikhin, Andrew Grimberg, jenkins-job-builder
Hi Aleksey,

The only reserved keywords in a "project" config are "name" and "jobs". Everything else in a project would be a variable.

Remember that a "project" section is for stating which jobs and job-templates you want to use and variables to pass into said job-templates. Typically you use a project to define several related jobs that you want to deploy for a project and pass in their related variables.

Job-templates themselves have other reserved keywords as well but anything you declare in curly braces are variables that need to be passed in from a project config.

Hope this helps,
Thanh

Aleksey Tsalolikhin

unread,
Jun 8, 2021, 5:05:18 PM6/8/21
to Thanh Ha, Andrew Grimberg, jenkins-job-builder
Well! That makes things a lot simpler.  Thanks, Thanh!!  That's actually hugely helpful.

Best,
Aleksey

Reply all
Reply to author
Forward
0 new messages