Shared Library: Converting a complete pipeline to a single step.

15 views
Skip to first unread message

Jochen Wiedmann

unread,
Jan 18, 2023, 9:00:00 AM1/18/23
to Jenkins Users

Hi,

I have a build job with the following pipeline, which works just fine:

    @Library('isccr-addons')_
    pipeline {
        agent any
        stages {
            stage ('init') {
                steps {
                    isccrExec "${ISCCR_ADDONS_CONFIG}", "${WORKSPACE}
            }
        }
    }

The "isccrExec" is a step, that's specified in my shared library.
I expect to have quite a lot of these build jobs. So, I am thinking
about moving as much code as possible to the shared library.
I have tried to create a new step "isccrPipeline" with the following
definition:

     pipeline {
        agent any
        stages {
            stage ('init') {
                steps {
                    isccrExec "${ISCCR_ADDONS_CONFIG}", "${WORKSPACE}
            }
        }
    }

Basically, that's just the same. Now I am trying to use that step with this
new build pipeline:

    @Library('isccr-addons')_
    isccrPipeline "${ISCCR_ADDONS_CONFIG}", "${WORKSPACE}

Unfortunately, that fails with this error message:

groovy.lang.MissingPropertyException: No such property: WORKSPACE for class: groovy.lang.Binding

Any ideas, what's wrong?

Thanks,

Jochen

Xavier Raynaud

unread,
Jan 18, 2023, 9:18:05 AM1/18/23
to jenkinsci-users
Hi,

AFAIK, WORKSPACE is defined per agent, not for a global pipeline.
For instance, if you run a pipeline on two distincts agents, each of them will have its own WORKSPACE



Xavier Raynaud
Integration & Release Manager • Kalray
Phone: +33 6 32 19 22 56
xray...@kalrayinc.comwww.kalrayinc.com


Please consider the environment before printing this e-mail.
This message contains information that may be privileged or confidential and is the property of Kalray S.A. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.



From: "Jochen Wiedmann" <jochen....@gmail.com>
To: "Jenkins Users" <jenkins...@googlegroups.com>
Sent: Wednesday, January 18, 2023 3:00:00 PM
Subject: Shared Library: Converting a complete pipeline to a single step.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/09e51da7-e421-44f7-b1c9-d169f9c19fc2n%40googlegroups.com.

Jochen Wiedmann

unread,
Jan 18, 2023, 9:22:52 AM1/18/23
to jenkins...@googlegroups.com

Okay, is there anything that I could use as a reference to the code directory instead?




--
Philosophy is useless, theology is worse. (Industrial Disease, Dire Straits)

christop...@googlemail.com

unread,
Jan 18, 2023, 10:12:58 AM1/18/23
to Jenkins Users
Jochen,

don't use ${WORKSPACE} from outside the pipeline, it will be available as soon as you are inside the pipeline with an agent.
That means: no need to have it as argument of your isccrPipeline

BR
Reply all
Reply to author
Forward
0 new messages