griddynamics / mpl

[IT-36925] Jenkins Shared Modular Pipeline Library
https://blog.griddynamics.com/developing-a-modular-pipeline-library-to-improve-devops-collaboration/
Apache License 2.0
158 stars 97 forks source link

Add new Stage in nested library #20

Closed enrique-fernandez-polo closed 5 years ago

enrique-fernandez-polo commented 5 years ago

Hello!! First of all... I love this project! I am migrating every pipeline of our organization. I've been looking for this kind of modular/composable/awesome Jenkins Shared library organization for a long time. Congratz!!

My problem is that I am trying to create a new pipeline in a nested library with a new stage like this.


stage('StaticCodeAnalysis') {
    when { expression { MPLModuleEnabled() } }
    steps {
        MPLModule()
    }
}

I am getting the following log message in Jenkins Stage "StaticCodeAnalysis" skipped due to when conditional

How can I "register" a new stage? I don't get how MPLModuleEnabled works.

Thans in advance!

enrique-fernandez-polo commented 5 years ago

Well this was easy...

MPLPipelineConfig(body, [
            agent_label: '',
            modules    : [
                    Checkout          : [:],
                    Build             : [:],
                    Deploy            : [:],
                    Test              : [:],
                    StaticCodeAnalysis: [:]
            ]
])

I just had to add the stage/module in the initial config.

sparshev commented 5 years ago

Hi @Quaiks, yeah that's because you used when { expression { MPLModuleEnabled() } } - and MPLModuleEnabled() is only true when MPL.config.modules[module_name] is not null.