Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile @Library @NonCPS using gradle in jenkins

I need to verify code changes in pipeline scripts (scripted pipeline), but I'm having a problem with compiling @Library and @NonCPS lines.

While doing task compile within gradle, I got errors:

unable to resolve class Library ,  unable to find class for annotation @Library('someLibrary') _

unable to resolve class NonCPS ,  unable to find class for annotation @NonCPS

I tried to include some external plugins within dependency like this:

dependencies {
    compile 'org.jenkins-ci.plugins.workflow:workflow-cps:2.41@jar'
    compile 'org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:2.4@jar'
    compile 'org.jenkins-ci.plugins:pipeline-utility-steps:1.5.0@jar'
    compile 'org.jenkins-ci.plugins.workflow:workflow-support:2.14@jar'
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    compile "org.jenkins-ci.plugins:job-dsl-core:${jobDslPluginVersion}"
    compile 'org.jenkins-ci.main:jenkins-core:1.609.3'
    compile 'org.jenkins-ci.plugins:build-pipeline-plugin:1.5.6'
    compile 'org.jenkins-ci.plugins:pipeline-build-step:2.5.1'
    compile 'org.jenkins-ci.plugins.pipeline-stage-view:pipeline-stage-view:2.9'
    compile 'org.jenkins-ci.plugins.workflow:workflow-cps:2.41'
    compile 'org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:2.4'
    compile 'org.jenkins-ci.plugins:pipeline-utility-steps:1.5.0'
    compile 'org.jenkins-ci.plugins.workflow:workflow-support:2.14'
}

but didn't work as expected.

I'm new to gradle so I might be missing some understanding.

like image 896
Tin Topolovec Avatar asked Mar 06 '23 15:03

Tin Topolovec


1 Answers

The NonCPS annotation type comes from the open source cloudbees/groovy-cps repository in the package com.cloudbees.groovy.cps.

You could add a compile dependency on something like compile('com.cloudbees:groovy-cps:1.22').

like image 171
mkobit Avatar answered Mar 09 '23 04:03

mkobit