1

I'm working on huge pipeline with different development environment (python, node, java). For manage this CI pipeline our teams using Jenkins at Kubernetes environment.

I want to give PipeLine node annotation at Groovy Script show as below .

 node("test-py") {
   sh "python -m -v py.test TEST_FILE.py "
 }

How I can create pod with image , with Jenkins Kubernetes Plugin .

0

Have a look at the documentation presented here:

https://github.com/jenkinsci/kubernetes-plugin

You need to specify a Kubernetes pod in your pipeline. An example of your use case would look similar to this for a single python container. You'll notice that containers: [] expects an array so you can include additional containers.

def label = "mypod-${UUID.randomUUID().toString()}"

podTemplate(label: label, containers: [
    containerTemplate(name: 'python', image: 'python:3.7-alpine', ttyEnabled: true, command: 'cat'),
]) {
    node(label) {
        stage('Get a Python project') {
            git 'https://github.com/oğuz/project.git'
            container('python') {
                stage('Test a Python project') {
                    sh "python -m -v py.test TEST_FILE.py "
                }
            }
        }
    }
}
  • I've runned this template groovy script before . I found the code block at kubernetes plugin , by the default is JNLP_SLAVE at it is offical image at link: hub.docker.com/r/jenkinsci/jnlp-slave so that we change default : JNLP_SLAVE notation . Thanks for your answer :)) – ColossusMark1 Jul 23 '18 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.