dsl in jenkinsfile

timestamps { ansiColor('xterm') {
  node('built-in') {

    jobDsl (
      sandbox: true,
      scriptText: '''
        pipelineJob(\'github-demo\') {
          definition {
            cpsScm {
              scm {
                git {
                  remote { github(\'jenkinsci/pipeline-examples\') }
                }
              }
              scriptPath(\'declarative-examples/simple-examples/environmentInStage.groovy\')
            }
          }
        }
      '''
    ) // jobDsl

  } // node
}} // ansiColor | timestamps
  • or via ExecuteDslScripts
    step ([
      $class: 'ExecuteDslScripts' ,
        scriptText: """
          pipelineJob('dsl/guardian/demo') {
            definition {
              cpsScm {
                scm {
                  git {
                    remote { github('jenkinsci/pipeline-examples') }
                  }
                }
                scriptPath( 'declarative-examples/simple-examples/environmentInStage.groovy' )
              }
            }
          }
        """.stripIndent() ,
        sandbox: true
      ]) // steps
    

create folder

timestamps { ansiColor('xterm') {
  node('built-in') {

    jobDsl (
      ignoreExisting: true,
      sandbox: true,
      scriptText: '''folder(\'dsl\') {
        displayName(\'dsl\')
        description(\'for dsl demo\')
      }'''
    )

  } // node
}} // ansiColor | timestamps
  • or via ExecuteDslScripts
    step([
      $class: 'ExecuteDslScripts',
          scriptText: """
            folder('dsl/guardian') {
              displayName('guardian')
              description('for dsl guardian demo')
            }
          """ ,
          lookupStrategy: 'JENKINS_ROOT',
          removedJobAction: 'DELETE',
          removedViewAction: 'DELETE',
          sandbox: true
    ])
    
Copyright © marslo 2020-2024 all right reserved,powered by GitbookLast Modified: 2024-10-30 04:30:28

results matching ""

    No results matching ""