0
votes

I am working on creating jenkins job from groovy script using DSL plugin apis. I want to add 'Execute python script' as a step in jenkins job. Here is what I am doing following this post:

job('example') {
description('My first job')
displayName('Job DSL Example Project')
properties {
    sidebarLinks {
        // use uploaded image
        link('https://wiki.acme.org/', 'Wiki', '/userContent/wiki.png')
    }
}
steps {
    python{
        command(''' print("Hello")''')
        nature('python')
    }
  } 
}

In the generated job, the step added is "Python Builder" step as shown in image below. The output I currently getting Instead I wanted to have "Execute Python script" step as shown below. Required output

Note:I have installed the shining panda plugin.

1
Images and screenshots can be a nice addition to a post, but please make sure the post is still clear and useful without them. Don't post images of code or error messages. Instead copy and paste or type the actual code/message into the post directly. - user5226582
Thank you! I'll keep that in mind. Can you help me where am I going wrong. - PRANAV KULKARNI

1 Answers

1
votes

Job DSL only has built-in support for the Shining Panda plugin and will generate the "Python Builder" build step. The "Execute Python script" build step is provided by the Python plugin.

You can use a Configure Block to add that (or any other) build step:

job('example') {
  configure {
    it / 'builders' / 'hudson.plugins.python.Python' {
      command('print("Hello")')
    }
  }
}