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-2023 all right reserved,powered by GitbookLast Modified: 2024-03-12 15:01:28

results matching ""

    No results matching ""