There are three high-level methods of interaction with the declarative-linter
. The specific set you have requested is the CLI, with the specific subset of on the server itself. The documentation you referenced then references the CLI documentation to read how to form commands with the Jenkins CLI.
In general, the command on the server looks like:
java -jar jenkins-cli.jar [-s JENKINS_URL] [global options...] command [command options...] [arguments...]
When running on the server, you can use localhost for the URL. The full path to the jenkins-cli
is also helpful to be safe (example shown below is for the RedHat family). Note you should use https
below instead if you are using a cert for the server.
java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ [global options...] command [command options...] [arguments...]
Now we substitute in the command and arguments specific to the declarative-linter
. Note we are using the stdin syntax specific to Linux.
java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ declarative-linter < /path/to/Jenkinsfile
That will allow local linting of your Jenkinsfile
via the jenkins-cli
on the Jenkins server. Note that if you need to authenticate, you need to substitute a -auth username:password
or -i /path/to/ssh_key
in the [global options...]
part of the command before declarative-linter
and after the argument for the Jenkins URL.