[JIRA] (JENKINS-42730) declarative-linter don't work with shared library

18 views
Skip to first unread message

etiennedh@yahoo.fr (JIRA)

unread,
Mar 13, 2017, 6:16:02 PM3/13/17
to jenkinsc...@googlegroups.com
Boudoux Etienne created an issue
 
Jenkins / Bug JENKINS-42730
declarative-linter don't work with shared library
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2017/Mar/13 10:15 PM
Environment: last jenkins.
all plugins up-to-date
Priority: Minor Minor
Reporter: Boudoux Etienne

I have a jenkinsfile which call shared library at the beginning

@Library('gconftools')
import forjenkins.GetNodes

this jenkinsfile work correctly, but when I want to test with declarative-linter, there is an error.

java -jar /var/lib/jenkins/home/war/WEB-INF/jenkins-cli.jar -s http://serveur.domainperso:8082 declarative-linter --username=user --password mdp <script.groovy

Errors encountered validating Jenkinsfile:
WorkflowScript: 7: unable to resolve class forjenkins.GetNodes
 @ line 7, column 1.
   @Library('gconftools')
   ^

WorkflowScript: 26: unable to resolve class forjenkins.GetNodes 
 @ line 26, column 7.
                z = new forjenkins.GetNodes()
         ^
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Mar 13, 2017, 6:31:01 PM3/13/17
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-42730
 
Re: declarative-linter don't work with shared library

First, I'd suggest upgrading to Declarative 1.1 and using the new libraries directive -

pipeline {
  agent any
  libraries {
    lib('gconftools')
  }
  stages {
    ...
  }
}

And then let me know if that works, and if not, what the error is along with (ideally) a copy of the Jenkinsfile having the problem.

etiennedh@yahoo.fr (JIRA)

unread,
Mar 16, 2017, 6:10:01 PM3/16/17
to jenkinsc...@googlegroups.com

hi,

I don't see any doc for this new libraries directive.

do you have a working example?

 

thank

 

etiennedh@yahoo.fr (JIRA)

unread,
Mar 19, 2017, 5:14:01 PM3/19/17
to jenkinsc...@googlegroups.com

nicos.maris@gmail.com (JIRA)

unread,
Mar 13, 2018, 8:00:03 AM3/13/18
to jenkinsc...@googlegroups.com

sirine.beji.1994@gmail.com (JIRA)

unread,
Jul 9, 2018, 4:31:02 AM7/9/18
to jenkinsc...@googlegroups.com
Sirine Beji commented on Bug JENKINS-42730
 
Re: declarative-linter don't work with shared library

Raul Arabaolaza  Did you try that code ? because it returns the same error as Matthew Mitchell

Did someone figured out this error ?

This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

it@mockies.de (JIRA)

unread,
Apr 24, 2020, 5:21:02 AM4/24/20
to jenkinsc...@googlegroups.com

The workaround of Raul Arabaolaza is working for me. Instantiating the object before it is used inside the shared library itself.

So something like

def lib = library("libs")
def o = lib.com.package.classA.new()

customStep() // step which is defined in "lib" and also instantiates classA

o.method()

works, while something like

def lib = library("libs")

customStep() // step which is defined in "lib" and instantiates classA

lib.com.package.classA.new().method()

does not

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

it@mockies.de (JIRA)

unread,
Apr 24, 2020, 5:40:02 AM4/24/20
to jenkinsc...@googlegroups.com
The workaround of [~rarabaolaza] is working for me. Instantiating the object before it is used inside the shared library itself.

So something like
{code:java}

def lib = library("libs")
def o = lib.com.package.classA.new()

customStep() // step which is defined in "lib" and also instantiates classA

o.method()
{code}
works, while something like
{code:java}

def lib = library("libs")

customStep() // step which is defined in "lib" and instantiates classA

lib.com.package.classA.new().method() // java.lang.IllegalAccessException
{code}
does not
Reply all
Reply to author
Forward
0 new messages