String script = PipelineScript.create()
.setAgent(...)
.addStage(checkoutFromGit(...))
.addStage(Stage.create('Static Code Analysis')
.addStep(sh('./gradlew condenarcMain'))
.addPost(Post.Condition.Always, publishHtml(...)))
.addPost(Post.Condition.FAILURE, deleteDir())
new PipelineJobBuilder(this as DslFactory, projectName)
.build(script)
--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1_KFxTjnEiddcwZv%3D7jndJvgX%2BgRp%3DUL5DeB5bmx%2B7%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
pipelineJob('example'){ definition { cps{ script("""pipeline { agent none stages { stage('Stage 1') { stage('Build Stage') { agent { node { label 'windowsBuilderServer' } } steps { checkout([$class: 'GitSCM', branches: [[name: env.ghprbActualCommit]], browser: [$class: 'GithubWeb', repoUrl: "XX"], doGenerateSubmoduleConfigurations: false, poll: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "YY", url: "XX.git"]]]) stash includes:"ProjectName/**/*", name:"stash1"
} post { always { deleteDir() } } } } stage('Stage 2') { parallel { stage('Parallel 1') { agent { node { label 'linuxBuildServer' } } steps { deleteDir() unstash name:"stash1" sh """some script""" } post { success { deleteDir() } always { archiveArtifacts artifacts:"*.e*,*.o*", excludes:"", allowEmptyArchive:true, fingerprint:true, onlyIfSuccessful:false junit allowEmptyResults: true, testDataPublishers: [[$class: 'AttachmentPublisher'], [$class: 'StabilityTestDataPublisher']], testResults: 'test_results/*.xml' } } } } } }} """) sandbox() }}
Stage stage1 = Stage.create('Stage 1') .setAgent(Agent.fromExecutor(Executor.WINDOWS)) .addStep(checkoutFromGit('XX', 'env.ghprbActualCommit')) .addStep(stash('stash1', 'ProjectName/**/*')) .addPost(Post.Condition.ALWAYS, deleteDir()) ParallelStage stage2 = ParallelStage.create('Stage 2')
//datasetList is a List<String> such that each string is a data set name//The following will create a prallel stage for each list element datasetList.collect { Stage.create(it) .setAgent(Agent.fromExecutor(Executor.LINUX)) .addStep(deleteDir()) .addStep(unstash('stash1')) .addStep(sh("""some script""")) .addPost(Post.Condition.SUCCESS, deleteDir()) .addPost(Post.Condition.ALWAYS, archiveArtifacts('*.e*,*.o*','',true, true,false)) .addPost(Post.Condition.ALWAYS, publishJUnitXml('test_results/*.xml', true)) }.each { stage2 = stage2.addStage(it) }
def script = PipelineScript.create() .addStage(stage1) .addParallelStage(stage2)
pipelineJob('example'){ definition { cps{ script(script) sandbox() }}