How can I make embedded resource in taskRun using fabric8::tekton-client

2/4/2020

I'm using fabric8::tekton-client(v4.7.1) to make "taskRun" object.

below is a sample code to make taskRun.

public TaskRun createTaskRun() {
    TaskRun tr = new TaskRunBuilder()
    .withApiVersion("tekton.dev/v1alpha1")
    .withNewMetadata()
        .withName("sample-taskrun")
        .endMetadata()
    .withNewSpec()
        .withServiceAccountName("build-bot")
        .withTaskRef(
            new TaskRefBuilder().withName("s2i").withApiVersion("tekton.dev/v1alpha1").withKind("Task").build()
        )
        .withNewInputs()
            .addNewParam()
                .withName("BUILDER_IMAGE")
                .withValue(new ArrayOrString("docker.io/centos/nodejs-8-centos7"))
            .endParam()
            .addNewResource()
                .withNewName("source")
                    .withNewResourceSpec()
                        .withType("git")
                        .addNewParam("url", "https://github.com/sclorg/nodejs-ex")
                    .endResourceSpec()
                .endPipelineResourceBinding()
            .endResource()
        .endInputs()
        .withNewOutputs()
            .addNewResource()
                .withName("image")
                .withNewResourceSpec()
                    .withType("image")
                    .addNewParam("url", "192.168.6.82:5000/nodejs-ex")
                .endResourceSpec()
            .endResource()
        .endOutputs()
    .endSpec().build();

    return tr;
}

In this code,

.withName("source")

makes an error: "error: cannot find symbol".

But latest tekton pipeline(v0.10.1) spec allows embedded resources and also their name field in taskRun.

How can I declare embedded resources in taskRun using fabric8::tekton-client(v4.7.1)?

-- jwkim93
fabric8
java
kubernetes
tekton-pipelines

0 Answers