zl程序教程

您现在的位置是:首页 >  Java

当前栏目

VScode本地进行Jenkinsfile语法验证

2023-02-18 16:47:59 时间

background(背景) Pipeline As Code is a core feature of Jenkins2.0. Not only learn the pipeline syntax, we also had to do a local basic syntax check on each Jenkinsfile commit to git repo. Pipeline As Code 是Jenkins的核心特性。我们不仅要学习Pipeline语法,还要对每次提交的Jenkinsfile进行本地基本语法检查。

VScode Plugin 插件

VScode是一款应用广泛且功能强大的开发人员编辑器。我们通常使用VScode来开发Jenkinsfile。对Jenkinsfile进行本地检查,需要安装Jenkins Pipeline Linter Connector插件。该插件的工作原理是调用远程的Jenkins API /pipeline-model-converter/validate.

Install Plugin (安装插件)

image.png

Plugin Settings (插件设置)

image.png

This extension contributes the following settings:

  • jenkins.pipeline.linter.connector.url: Url of the Jenkins Pipeline Linter.
  • jenkins.pipeline.linter.connector.crumbUrl: Url of the Jenkins Crumb Issuer.
  • jenkins.pipeline.linter.connector.pass: Jenkins password (can be left blank if you don't want to put your password in your settings).
  • jenkins.pipeline.linter.connector.token: Jenkins token (can be left blank if you don't want to put your token in your settings).
  • jenkins.pipeline.linter.connector.user: Jenkins username.
  • jenkins.pipeline.linter.connector.strictssl: Set to false to allow invalid ssl connections.

Example:

Write Jenkinsfile

run Command Palette

click Validate Jenkinsfile

Get run result: