Skip to content

yeshan333/vscode-jenkins-pipeline-linter-connector

Repository files navigation

jenkins-pipeline-linter-connector

Open VSX Version Visual Studio Marketplace Version

This extension validates Jenkinsfile by sending them to the Jenkins Pipeline Linter of a Jenkins server. Also support to review Jenkinsfile with LLMs.

Features

Example Usage

Example

Example with syntax error

Extension Settings

This extension contributes the following settings:

  • jenkins.pipeline.linter.connector.url: is the endpoint at which your Jenkins Server expects the POST request, containing your Jenkinsfile which you want to validate. Typically this points to <your_jenkins_server:port>/pipeline-model-converter/validate.
  • jenkins.pipeline.linter.connector.crumbUrl: has to be specified if your Jenkins Server has CRSF protection enabled. (eg: https://<your-jenkins-server>:<port>/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)).
  • jenkins.pipeline.linter.connector.user: allows you to specify your Jenkins username.
  • jenkins.pipeline.linter.connector.pass: allows you to specify your Jenkins password.
  • jenkins.pipeline.linter.connector.token: Jenkins user API token.
  • jenkins.pipeline.linter.onsave: controls whether the Jenkinsfile is checked immediately after it is saved (default: false).
  • jenkins.pipeline.linter.checkextensions: you can control what file can be checked through this configuration. (default: [".jenkinsfile", ".groovy", "Jenkinsfile"]). It means that the file name being checked must contains one of them.

example settings

Scenario 1: Jenkins does not have API authentication enabled

{
    "jenkins.pipeline.linter.connector.url": "https://jenkins.shan333.cn/pipeline-model-converter/validate",
}

Scenario 2: Jenkins has API authentication enabled. Use a password for authentication.

{
    "jenkins.pipeline.linter.connector.url": "https://jenkins.shan333.cn/pipeline-model-converter/validate",
    "jenkins.pipeline.linter.connector.user": "jenkins_username",
    "jenkins.pipeline.linter.connector.pass": "jenkins_password",
    "jenkins.pipeline.linter.connector.token": "user_api_token"
}

Scenario 3: Jenkins has API authentication enabled. Use a API token for authentication.

{
    "jenkins.pipeline.linter.connector.url": "https://jenkins.shan333.cn/pipeline-model-converter/validate",
    "jenkins.pipeline.linter.connector.user": "jenkins_username",
    "jenkins.pipeline.linter.connector.token": "user_api_token"
}

Scenario 4: Jenkins has API authentication enabled and CRSF protection enabled.

{
    "jenkins.pipeline.linter.connector.url": "https://jenkins.shan333.cn/pipeline-model-converter/validate",
    "jenkins.pipeline.linter.connector.user": "jenkins_username",
    "jenkins.pipeline.linter.connector.pass": "jenkins_password",
    "jenkins.pipeline.linter.connector.token": "user_api_token",
    "jenkins.pipeline.linter.connector.crumbUrl": "https://jenkins.shan333.cn/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)"
}

Enable review with LLM

You can also enable linter with LLMs. We use the Cloudflare ("赛博佛祖") Workers AI REST API to get reviews of your Jenkinsfile.

enable review with LLM

This is an example configuration to enable this feature:

{
    "jenkins.pipeline.linter.connector.llm.enable": true,
    "jenkins.pipeline.linter.connector.llm.baseUrl": "https://api.cloudflare.com/client/v4/accounts/<CF_ACCOUNT_ID>/ai/v1",
    "jenkins.pipeline.linter.connector.llm.modelName": "@cf/meta/llama-2-7b-chat-fp16",
    "jenkins.pipeline.linter.connector.llm.apiKey": "<CF_API_TOKEN>",
}

Acknowledgements

Packages

No packages published

Languages

  • TypeScript 100.0%