ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Jenkinsfile

by june07 ALL

Lint Jenkins' Jenkinsfile via SSH

Details

Installs

  • Total 3K
  • Win 3K
  • Mac 378
  • Linux 169
Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6
Windows 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 2 0 1 0 1 0 2 0 0 0 0 1 0 2 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2
Linux 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0

Readme

Source
raw.​githubusercontent.​com

sublime-Jenkinsfile

Jenkinsfile is a plugin for Sublime Text that gives you easy access to the Jenkins declarative-linter via a secure mechanism, SSH or HTTPS.

https://packagecontrol.io/packages/Jenkinsfile

  • Securely (ssh, https) lint your Jenkinsfile (What is a Jenkinsfile?) inside of Sublime Text
  • Lint against Jenkins cloud instance if ssh access is unavailble on your primary environment
  • Magic

Jenkins includes Pipeline Development Tools as shown on Jenkins.io

Jenkins can validate, or “lint”, a Declarative Pipeline from the command line before actually running it. This can be done using a Jenkins CLI command or by making an HTTP POST request with appropriate parameters. We recommended using the SSH interface to run the linter. See the Jenkins CLI documentation for details on how to properly configure Jenkins for secure command-line access.

Technology

Jenkinsfile uses a number of open source projects to work properly: * Python - a programming language changes the world * SSH - a cryptographic network protocol for operating network services securely over an unsecured network

And of course Jenkinsfile itself is open source with a public Git repository on GitHub.

How to install

With Package Control: 1. First step is done with Package Control or manually

- **With Package Control**
Run “Package Control: Install Package” command, find and install Jenkinsfile plugin.

- **Manually** *(without Package Control)*:
Clone or download from [git][jenkinsfilegh] into your packages folder (in ST, find Browse Packages (in ST4 it's under Preferences)… menu item to open this folder).
note: You must clone or download into a directory named "Jenkinsfile" and not sublime-Jenkinsfile.

![image](https://user-images.githubusercontent.com/11353590/219444106-d6207f7e-e872-48d2-80b0-b715c65acd25.png)
  1. Restart Sublime Text (if required)

Setup

Currently you must use Pageant (Windows) to create a session that can authenticate via ssh to your Jenkins host.
You can now use this plugin via two methods either via Pageant on Windows or via plain SSH.

  1. Using via SSH (Linux, OSX, or Windows):
    • Set the jenkins_ssh_user (default admin), jenkins_ssh_host (default localhost), and jenkins_ssh_port (default 22) configuration values to match that of your Jenkins server.

    • Note: On Windows you must clear the pageant_session configuration variable to use SSH.
  2. Or for a Pageant setup on Windows:
    • The name of the session must match the configured value of pageant_session (default is “jenkins”) as shown:

Usage

Now whenever you have are editing a Jenkinsfile (filename needs to include Jenkinsfile) and save the file, the plugin will invoke the remote instance of the Jenkins declarative-linter… either configured via SSH credentials or a hosted Jenkins declarative-linter HTTPS endpoint such as https://api.brakecode.com/api/v1/jenkinsfile.

Hosted Jenkins Declarative Linter Enpoint

Given a configuration file with the following included:

"jenkins_http_endpoint": "https://api.brakecode.com/api/v1/jenkinsfile"

you will have access to the BrakeCODE hosted endpoint of the Jenkins declarative linter and be able to use a limited amount of free API calls.

By default this endpoint is not configured. The server resources are entirely owned by the author of this plugin, however as your Jenkinsfile will be sent (securely) to infrastructure outside of your control, it was thought best to leave this as a feature which required clear user intent and configuration. Currently, no analytics or other data collection is done.

image

The file can also be linted without saving by using the keyboard shortcut (cntl-alt-j by default)

Todos

  • Add support for Linux (done 2/16/23!), All OSs are not supported via SSH.
  • Add hosted Jenkins validation (done 2/20/2023)

License

MIT

.