How to implement writing to console log in pipeline?

32 views
Skip to first unread message

tzach....@gmail.com

unread,
Nov 19, 2023, 5:50:48 AM11/19/23
to Jenkins Developers
Hi,

I'm developing a new plugin and I was able to write to log in FreeStyleJob  but it does not work in pipeline. What I have done is:

1. Extend ParameterValue class
2. Override createBuildWrapper and return new SimpleBuildWrapper. In it, override setup() method and used the listener to reach the logger. But, this does not work in pipleine (i'm guessing because it has AbstractBuild as input)

This is my code:
 
    @Override
    public BuildWrapper createBuildWrapper(AbstractBuild<?, ?> build) {
        return new SimpleBuildWrapper() {

            @Override
            public boolean requiresWorkspace() {
                return false;
            }

            @Override
            public void setUp(Context context, Run<?, ?> build, TaskListener listener, EnvVars env) {
                listener.getLogger().println("*** My plugin works ***");

My question is, what do I need to do in order to be able to println also to console plugin?

Thanks,
Tzach




tzach solomon

unread,
Nov 20, 2023, 3:24:23 PM11/20/23
to jenkin...@googlegroups.com
Anyone?

Tzach 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f0bd9a71-43e4-4f05-9f41-c05b202aaa8bn%40googlegroups.com.

Basil Crow

unread,
Nov 20, 2023, 4:38:32 PM11/20/23
to jenkin...@googlegroups.com
On Sun, Nov 19, 2023 at 2:50 AM tzach....@gmail.com
<tzach....@gmail.com> wrote:
> I'm developing a new plugin and I was able to write to log in FreeStyleJob but it does not work in pipeline.

See https://www.jenkins.io/doc/developer/plugin-development/pipeline-integration/
for more information: Pipeline builds are instances of WorkflowRun and
therefore ParameterValue#createBuildWrapper(AbstractBuild) does not
apply to them. It is difficult to give a concrete suggestion without
seeing your code, but you may wish to refer to the tests in the
Pipeline plugins for examples.
Reply all
Reply to author
Forward
0 new messages