Invoking a declarative pipeline from shared libraries

39 views
Skip to first unread message

ctrlengi...@gmail.com

unread,
May 15, 2017, 7:22:20 AM5/15/17
to Jenkins Users
Hi,

I am trying to invoke my declarative pipeline from shared libraries (so my jenkinsfile is as brief as possible) but it doesn't seem to work properly and the "pipeline" block seems to get executed, but functions like "when" are not evaluated...

Jenkinsfile:

#!groovy
def application = Constants.SONARQUBE_POC
def build = new org.ppluk.JenkinsPipelineBootstrap().setupBuild(application.name, application.next_version)


Shared library:
#!groovy
// vim: set syntax=groovy:
// Author: 
// Description: Declarative Pipeline Bootstrap actions

package org.ppluk


String setupBuild(String applicationName, String nextVersion) {
pipeline {
    agent { label "Java" }
    tools { maven "M3" }
    stages {
        stage('test') {
            when { branch "feature/*" }
            steps {
                echo "helloworld"
            }
        }
    }
}}

Is what I am attempting to do actually possible?


Sebastien Crete

unread,
Sep 13, 2017, 2:25:00 PM9/13/17
to Jenkins Users
Where you define your shared libraries ?

with shared-lib in DP .... i think is ncessary define in vars ... so your vars/myfile can call some lib ....

https://stackoverflow.com/questions/44943438/jenkins-shared-library-instantiate-util-class-and-use-in-workflowscript

i think ...

Andrew Bayer

unread,
Sep 13, 2017, 6:57:00 PM9/13/17
to jenkins...@googlegroups.com
See https://issues.jenkins-ci.org/browse/JENKINS-46547 - this will probably make it into Declarative 1.3, landing hopefully end of October.

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0c4059ee-4d53-40de-b6a2-de299352e08c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages