Jenkinsfile naming convention

1,485 views
Skip to first unread message

Kris Z

unread,
May 14, 2020, 10:24:15 AM5/14/20
to Jenkins Users
Hello,

I was reading the documentation for Jenkins User Handbook (https://www.jenkins.io/doc/book/getting-started/), specifically the section on Pipeline and creating the Jenkins file.  

My specific question is, why isn't the Jenkinsfile named Jenkinsfile.groovy?  

When adding the extension all the operating systems have tools to open a file with editor and they launch syntax highlighting.


Alan Sparks

unread,
May 14, 2020, 11:29:14 AM5/14/20
to Jenkins Users
I think historical convention.  It's not a huge deal, you can use any file name you want, if you set your pipeline job up to use your path/filename instead of the default.

Kris Z

unread,
May 14, 2020, 2:22:20 PM5/14/20
to Jenkins Users
I'm not sure how to define "huge deal".  I think it really has to do with someone not thinking things through when they document on the Jenkins website: https://www.jenkins.io/doc/pipeline/tour/hello-world/ .

I mean, it's going backwards several decades.  As of now, all operating systems: Linux, Mac, Windows, and others understand the concept of having a file extension.  I use Linux as my default development environment.  Unix-like operating systems have also come as far as adding a shebang to the top of the file to all files which include source code that is a scripting language.  This concept of using a shebang is very well understood in Unix-like operating systems.

There are so many scripting languages out there, how could I tell what language is being used within a Jenkinsfile?  I mean it is using Groovy and the Jenkins team is not creating a new scripting language.  It should be explicitly indicating that Groovy is being used by the following:
  1. Adding a ".groovy" to the "Jenkinsfile" example, so it is "Jenkinsfile.groovy".
  2. Adding a cross-platform compatible shebang to the top of the file:
    1. Example source code:
      1. #!/usr/bin/env groovy


    2. Example screenshot:
    3. test_groovy_example.png


I scoured other training material and I see people that call themselves "trainers" (especially on YouTube) and create files that have a ".pipeline" extension.  Which is wrong.  If the file is a Groovy scripting language it should be named "pipeline_x.groovy".  This way the development tools on Linux can automatically perform syntax highlighting and file type assesment.

How could I submit a defect against the documentation to have this looked at and changed?

Alan Sparks

unread,
May 14, 2020, 2:53:47 PM5/14/20
to Jenkins Users
Perhaps the phrase "not a huge deal" was ill-advised, apologize for that.
Am not sure from the documentation you reference that it's a documentation problem - does it not consistently reference "Jenkinsfile"?  Since the default pipeline definition in a pipeline job (with pipeline from SCM) is Jenkinsfile, the documentation seems right to me (from standpoint of documenting reality).

Calling it Jenkinsfile.groovy isn't 100% accurate, since the content of that file isn't idiomatic Groovy.  Supports a lot of Groovy-ish constructs, but isn't Groovy proper. Jenkinsfile.pipeline would make sense, as it is a pipeline definition. I understand that a ".pipeline" extension isn't recognized by many tools as a text file construct.  Although, most tools would allow you to map extensions as desired.

Seems unlikely that the historical name "Jenkinsfile" would be changed.  I've been known to create multiple pipeline files in a repository, and to name them with schema "foobar.pipeline".  I think that's a preference, and to each their own.

Mark Waite

unread,
May 14, 2020, 2:55:28 PM5/14/20
to Jenkins Users
On Thu, May 14, 2020 at 12:22 PM Kris Z <krisdev...@gmail.com> wrote:
I'm not sure how to define "huge deal".  I think it really has to do with someone not thinking things through when they document on the Jenkins website: https://www.jenkins.io/doc/pipeline/tour/hello-world/ .


Thanks for your interest.  The "getting started" page includes a suggestion to use the shebang line at the top of the file.  It says:

image.png
 

I scoured other training material and I see people that call themselves "trainers" (especially on YouTube) and create files that have a ".pipeline" extension.  Which is wrong.  If the file is a Groovy scripting language it should be named "pipeline_x.groovy".  This way the development tools on Linux can automatically perform syntax highlighting and file type assesment.


I've never encountered anyone that suggests creating a Jenkinsfile with a ".pipeline" extension.  That file name wouldn't help me.

I disagree that the file name should be Jenkinsfile.groovy, especially since I don't find the declarative pipeline syntax to feel much like groovy and there are many places where the Jenkinsfile DSL is not groovy, but rather a subset of groovy that was intentionally selected when the domain specific language was being defined.
 
How could I submit a defect against the documentation to have this looked at and changed?

Each documentation page includes links in the lower left corner of the page.  One of those links is "Improve this page".  The other is "Report a problem".

Thanks,
Mark Waite
 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/23d00a11-4458-4e72-8e7c-76846b56ce4d%40googlegroups.com.

Jérôme Godbout

unread,
May 14, 2020, 4:20:30 PM5/14/20
to jenkins...@googlegroups.com

Probably because only one OS (read Windows here) only rely on extension to open file. The shebang is enough on most system. Pipeline Groovy is not pure groovy, the script into pipeline is a Frankenstein of Groovy and Jenkins features. Like some other point out, it should have been .pipeline or .jenkins or something like that. Really wish they went standard on this one, it make horrible scripts that aren’t reusable anywhere else. I mostly just call python script and gave up on the NON CPS and weird loop behavior, did anyone said script approval madness??? At least my python script can be reuse without the need of the Jenkins special env. Some would say this is a security breach, but I prefer having secure repository and Jenkins server, not the execution of the script per say, it’s grail run to try to secure from code execution like that, it will never be good, it just an annoyance. Wish there was a fork without that script approval and no CPS. Let me secure the source of my Jenkins scripts (certificate and private key ok) and assume my dev know what they do, it’s not like they cannot access the code anyway.

--

You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Slide

unread,
May 14, 2020, 4:31:59 PM5/14/20
to Jenkins User Mailing List
Using external scripts is generally the preferred way of doing things anyway, so you are going the correct route. Writing scripts that reside in your SCM and then orchestrating them with a Jenkinsfile is the recommended way. As for the filename, most editors that I know of have a way to associating a filename with a language, I do this in VSCode to associate Jenkinsfile with groovy handling and it works just fine.



--

Dirk Heinrichs

unread,
May 15, 2020, 1:31:46 AM5/15/20
to jenkins...@googlegroups.com
Am Donnerstag, den 14.05.2020, 06:59 -0700 schrieb Kris Z:

When adding the extension all the operating systems

That's not quite true. Unix-like OS' don't need one since they identify files by content, not by extension. So, a proper shebang line at the top should be sufficient to identify your Jenkinsfile as being Groovy.

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
Reply all
Reply to author
Forward
0 new messages