Jenkins Pipeline with custom class does hang forever

359 views
Skip to first unread message

thomas....@teamaol.com

unread,
Oct 17, 2016, 4:35:00 AM10/17/16
to Jenkins Users
Hi,

I were trying to write custom class in Jenkinsfile.

With following example the JOb does hang after the line "echo hi:2". I have to click to abort the build and then click twice
on provided links in the Jenkins Console to fully cancel it. On our server - even after kill - Jenkins remains 200 and more percentage of CPU.
We were forced to shutdown the Service and to restart. Locally I'm running Jenkins inside a Docker container. No CPU problems there.
I'm using a 2.8 and on our server we have a 2.23.

The Console output looks like this:


And ideas?

Kind Regards,
Thomas

class Project implements Serializable {
    static final serialVersionUID = 1L
    
    private String message = ""
    
    def setMessage(String message) {
        this.message = message
    }
    
    def getMessage() {
        return this.message
    }
}

node {
    echo "hi:1"
    def project = new Project()

    stage("Using a class") {
        echo "hi:2"
        project.setMessage("some message")
        echo "hi:3"
        echo project.getMessage()
        echo "hi:4"
    }
}



Daniel Beck

unread,
Oct 17, 2016, 4:50:39 AM10/17/16
to jenkins...@googlegroups.com
> def setMessage(String message) {
> this.message = message
> }

This looks like a potential infinite loop, because Groovy allows calling setters by just setting the property. Probably something getting messed up in one of the Groovy transformations (because this is supposed to only happen for fields without access modifier, and only outside the class[1]).

Try this:

> this.@message = message

Or just skip the getters/setters while you don't need them.

1: http://groovy-lang.org/objectorientation.html#properties

thomas....@teamaol.com

unread,
Oct 17, 2016, 4:59:30 AM10/17/16
to Jenkins Users, m...@beckweb.net
Yeah ... found out that too ... "Thread dumps" link in Jenkins job has shown the multiplle calls.
Wasn't aware of the property cabability.

Thank you
Reply all
Reply to author
Forward
0 new messages