We have a Jenkins setup on Google Kubernetes Engine with dynamic kubernetes pods serving as build agents. I want to integrate Pylint as a build step. Python version running on kubernetes pod is 2.7.16. Any idea how to install Pylint and integrate it into Jenkins build?
Edit:
Jenkins is running on a Google Kubernetes Engine cluster.
Kubernetes Cloud is configured in Jenkins as given below:
List of plugins installed are as follows:
Analysis Model API Plugin
Ant Plugin
Apache HttpComponents Client 4.x API Plugin
Bundles Apache HttpComponents Client 4.x and allows it to be used by Jenkins plugins.
Authentication Tokens API Plugin
Bootstrap 4 API Plugin
Bootstrap 5 API Plugin
bouncycastle API Plugin
Branch API Plugin
Caffeine API Plugin
Checks API plugin
Command Agent Launcher Plugin
Credentials Binding Plugin
Credentials Plugin
DataTables.net API Plugin
Display URL API
Docker API Plugin
Docker Commons Plugin
Docker Pipeline
Docker plugin
Durable Task Plugin
ECharts API Plugin
Provides ECharts for Jenkins plugins.
Folders Plugin
Font Awesome API Plugin
Forensics API Plugin
Git
Git client plugin
GIT server Plugin
GitHub API Plugin
GitHub plugin
Google Authenticated Source plugin
Google Cloud Storage plugin
Google Compute Engine Plugin
Google Kubernetes Engine Plugin
Google Metadata plugin
Google OAuth Credentials plugin
Jackson 2 API Plugin
JavaScript GUI Lib: ACE Editor bundle plugin
JavaScript GUI Lib: Handlebars bundle plugin
JavaScript GUI Lib: jQuery bundles (jQuery and jQuery UI) plugin
JavaScript GUI Lib: Moment.js bundle plugin
JQuery3 API Plugin
JSch dependency plugin
JUnit Plugin
Kubernetes Client API Plugin
Kubernetes Credentials Plugin
Kubernetes plugin
LDAP Plugin
Lockable Resources plugin
Mailer Plugin
Matrix Project Plugin
Metrics Plugin
Monitoring
OAuth Credentials plugin
OkHttp
Oracle Java SE Development Kit Installer Plugin
OWASP Markup Formatter Plugin
Pipeline
Pipeline Graph Analysis Plugin
Pipeline: API
Pipeline: Basic Steps
Pipeline: Build Step
Pipeline: Declarative
Pipeline: Declarative Extension Points API
Pipeline: Groovy
Pipeline: Input Step
Pipeline: Job
Pipeline: Milestone Step
Pipeline: Model API
Pipeline: Multibranch
Pipeline: Nodes and Processes
Pipeline: REST API Plugin
Pipeline: SCM Step
Pipeline: Shared Groovy Libraries
Pipeline: Stage Step
Pipeline: Stage Tags Metadata
Pipeline: Stage View Plugin
Pipeline: Step API
Pipeline: Supporting APIs
Plain Credentials Plugin
Plugin Utilities API Plugin
Popper.js 2 API Plugin
Popper.js API Plugin
SCM API Plugin
Script Security Plugin
Snakeyaml API Plugin
SSH Agent Plugin
SSH Build Agents plugin
SSH Credentials Plugin
SSH plugin
SSH server
Structs Plugin
Token Macro Plugin
Trilead API Plugin
Variant Plugin
Warnings Next Generation Plugin
Jankins version is Jenkins 2.303.2, and all plugins are up-to-date to latest version.
CodePudding user response:
I think you probably can achieve the desired behavior by adding a convenient container to your pod template: this container will include the necessary Pylint dependencies and will be used in addition to the default Jenkins agent image in your pod.
As you can see in your screenshot, you can add this container when configuring your pod template and Kubernetes in the Jenkins Web console.
In addition, you can provide the necessary information when defining your pipeline. Consider for instance the example provided in the Jenkins Kubernetes plugin documentation:
podTemplate(containers: [
containerTemplate(name: 'maven', image: 'maven:3.8.1-jdk-8', command: 'sleep', args: '99d'),
containerTemplate(name: 'golang', image: 'golang:1.16.5', command: 'sleep', args: '99d')
]) {
node(POD_LABEL) {
stage('Get a Maven project') {
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
stage('Build a Maven project') {
sh 'mvn -B -ntp clean install'
}
}
}
stage('Get a Golang project') {
git url: 'https://github.com/hashicorp/terraform.git', branch: 'main'
container('golang') {
stage('Build a Go project') {
sh '''
mkdir -p /go/src/github.com/hashicorp
ln -s `pwd` /go/src/github.com/hashicorp/terraform
cd /go/src/github.com/hashicorp/terraform && make
'''
}
}
}
}
}
Please, note the definition of the required containers and how everyone of them is used in the pipeline.
You can review additional examples in the plugin Github repository.
This Jenkins blog post, is plenty of information about how to use these custom containers as well.
For your Pylint container template you can provide your own image although there are different ones already available in Docker hub, for instance.
I am not an expert in the use of Pylint, but I came across these related resources:
- Declarative Jenkins pipeline syntax for pylint or flake8
- Jenkins pipeline - skip next stage on conditional failure of pylint
- Use PyLint on Jenkins with Warnings Plugin and Pipeline
- Is there any Jenkins plugin for pylint results?
- Jenkins and Python
- Jenkins Python template
I hope some of them will be of help in your pipeline definition.