0

I want to use shared-library in my job dsl process, but it does not support the @Library.

@Library('shared-library')
def pipelineTemplate = {
  //String[] strArray = ${stages}.split(" ")
    pipelineJob("${serviceName}-pipeline", {
        definition {
            cps {
                script("""
                   @Library('shared-library')_
                    pipeline {
                        agent any
                        stages {
                            echo "Stages --> ${stages}"
                            ${stages.contains("build") ? buildStage() : " "} //build stage is a shared library
                            ${stages.contains("deploy") ? deployStage() : " "}
                    }
                """)
            }
        }
    })
}
pipelineTemplate()

Here, the buildStage() need to be invoked from shared library, but that doesnt seem to work here

  • Why do you have `@Library()` twice? Can you try `@Library('shared-library') _` on the top instead? – Laurean Ray Bahala May 04 '23 at 10:38
  • @LaureanRayBahala The pipeline I am trying to build also needs shared-library and thats why I have added it! I tried only having it on the top too, it did not work. I guess job dsl doesn't support annotations – RAJARAJESHWARIE .K May 16 '23 at 12:42

0 Answers0