Hello list,

We are busy converting our jobs to the Multibranch Pipeline.

We had a lot of jobs generated by the JobDSL.
- Build develop
- Build feature branches
- Sonar builds for develop and feature branches

We configured our jobs in the same repository as our JobDSL.

For the Multibranch Pipeline, we want to create a shared library, so we can
have a common ground for all our old jobs.

We based our shared library on one we found on Github [1] and called the
builder as follows:

@Library('chefci') _
org.typo3.chefci.v2.cookbook.CookbookPipeline.builder(this, steps)
        .buildDefaultPipeline()
        .execute()

Then we wanted to change the stages to suit our needs and created a Maven stage:

@Override
void execute() {
    script.stage(stageName) {
        script.when(script.branch('feature/*'))
        script.withMaven(
                mavenSettingsConfig: 'e6609549-d884-4978-9750-61bdb982db2e',
                publisherStrategy: 'EXPLICIT',
                options: [
                        script.pipelineGraphPublisher(),
                        script.mavenLinkerPublisher(),
                        script.junitPublisher(healthScaleFactor: 1.0),
                        script.dependenciesFingerprintPublisher(),
                        script.artifactsPublisher()],
        ) {
            script.sh "mvn clean --batch-mode --update-snapshots
-Pintegration deploy"
        }
        script.chuckNorris()
    }
}

This didn't work, because of the `script.when` line.

Is it possible to have a `when` block when using this method?

Also, is this a good way to setup a shared library for the declarative
pipeline? Are there anymore good examples? I find a lot of
documentation, but a lot is unclear if it is for the scripted or
declarative pipeline.

I hope someone can help me with this.

With regards,

Nick Stolwijk

[1]
https://github.com/TYPO3-infrastructure/jenkins-pipeline-global-library-chefci

~~~ Try to leave this world a little better than you found it and, when
your turn comes to die, you can die happy in feeling that at any rate you
have not wasted your time but have done your best ~~~

Lord Baden-Powell

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA9S6i4aHrricHZ%3Da1g9h84JaGn3rGU7Fw5khFJt5zOoMEepkQ%40mail.gmail.com.

Reply via email to