How to Validate Jenkinsfile using Visual Studio Code

In this article we are going to learn Install Jenkins Pipeline Linter Connector extension in VS code, How to Validate Jenkinsfile using Visual studio code.

Pr-requisites:

  • Jenkins Server with User credentials
  • Preinstalled Visual Studio Code
  • Jenkins Pipeline Linter Connector for Visual Studio Code.

Step #1:Install Jenkins Pipeline Linter Connector extension in VS code 

Install Jenkins Pipeline Linter Connector extension in your Extension panel in Visual studio code.

How to Validate Jenkinsfile using Visual Studio Code 1

Once the installation process is finished, you need to configure it. Go to the Settings section in VS Code. In the “Search settings” field write “Jenkins”.

Connector Pass: Enter your Jenkins user password here.

Connector URL: Enter your Jenkins server URL here.(using below format)

https://<JENKINS SERVER URL>/pipeline-model-converter/validate

Connector User: Enter your Jenkins username here.

How to Validate Jenkinsfile using Visual Studio Code 2
img2

Now it’s done open your Jenkinsfile.¬†

This is our example of how a Jenkinsfile looks:

pipeline{
    agent any
    stages{
        stage('Jenkins first Demo'){
            steps{
                echo "welcome to devopshint"
            }

        }
    }
}
How to Validate Jenkinsfile using Visual Studio Code 3
img 3

Step #2:Validate Jenkinsfile using Visual Studio Code

Go to View menu -> command palette

Open the Command Palette (In VS code go to view and then open command palette) and write “Validate Jenkins”

How to Validate Jenkinsfile using Visual Studio Code 4

If the syntax of your file is valid, you’ll have a message like this.

How to Validate Jenkinsfile using Visual Studio Code 5
img 4

Conclusion:

In this article we have covered Install Jenkins Pipeline Linter Connector extension in VS code, How to Validate Jenkinsfile using Visual studio code.

Reference:

Validate jenkinsfile using visual studio code official page

Related Articles:

How to Install GitLab Runner on Ubuntu 22.04 LTS

Shweta Mamidwar

I am Shweta Mamidwar working as a Intern in Product Company. Likes to share knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap