-1

I want to convert it to Pipeline script. I have the following Jenkins 'Pipeline script from SCM':

enter image description here

enter image description here

enter image description here

How can I convert this to the 'Pipeline script'. I want to do this to make use of some Jenkin plugins. I know there is a 'Pipeline Syntax' helper at the bottom, but I'm not sure what I should look for to convert the Repository URL or credentials or script path.

I've looked online, but haven't found any direct methodology to do this.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Huckleberry Carignan
  • 2,002
  • 4
  • 17
  • 33

1 Answers1

0

You can't convert what you have shown to Jenkins DSL since you first need to specify the script that you will be running with DSL. That specification is done here and has to be done in this specific way. Then you can write Jenkins DSL code in the script you have specified at the bottom.

If you are asking about how you can checkout a repo with those credentials from inside the script file, you can use the GITSCM plugin. For example:

checkout scmGit(
    branches: [[name: 'v4.11.x']],
    userRemoteConfigs: [[credentialsId:  'my-ssh-private-key-id',
        url: 'ssh://github.com/jenkinsci/git-plugin.git']])

Detailed info on how you can do that can be found in the doc

M B
  • 2,700
  • 2
  • 15
  • 20
  • How can I kick off a groovy file? – Huckleberry Carignan Apr 21 '23 at 18:16
  • You mean run another groovy file from within your script? – M B Apr 22 '23 at 05:00
  • Yea, so Jenkins "Script Pipeline from SCM" calls and runs a groovy file? Can I just call and run it from the 'Pipeline script'? – Huckleberry Carignan Apr 22 '23 at 13:58
  • The Pipeline script still expects structured pipeline code, so you will have to define a stage. After that you can load a groovy file onto that stage and use the functions defined there. [This section](https://youtu.be/7KCS70sCoK0?t=1653) of a video shows how that is done. – M B Apr 23 '23 at 03:46