/busybox/sh: syntax error: bad substitution with Tekton

735 views Asked by At

I'm trying to pull source code from Github then build and push a docker image to docker hub using Tekton pipeline and Knative on Kubernetes cluster. I'm following this link for the installation and setup of Tekton: https://www.ibm.com/cloud/blog/build-a-knative-service-with-tekton-and-apache-openwhisk-nodejs-runtime

task-build.yaml

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: task-build
spec:
  inputs:
    resources:
      - name: docker-source
        type: git
    params:
      - name: TARGET_IMAGE_NAME
        description: name of the image to be tagged and pushed
      - name: TARGET_IMAGE_TAG
        description: tag the image before pushing
        default: "latest"
      - name: DOCKERFILE
        description: name of the dockerfile
      - name: OW_RUNTIME_DEBUG
        description: flag to indicate debug mode should be on/off
        default: "false"
      - name: OW_RUNTIME_PLATFORM
        description: flag to indicate the platform, one of ["openwhisk", "knative", ... ]
        default: "knative"
      - name: OW_ACTION_NAME
        description: name of the action
        default: "foo"
      - name: OW_ACTION_CODE
        description: JavaScript source code to be evaluated
        default: ""
      - name: OW_ACTION_MAIN
        description: name of the function in the "__OW_ACTION_CODE" to call as the action handler
        default: "main"
      - name: OW_ACTION_BINARY
        description: flag to indicate zip function, for zip actions, "__OW_ACTION_CODE" must be base64 encoded string
        default: "false"
      - name: OW_HTTP_METHODS
        description: list of HTTP methods, any combination of [GET, POST, PUT, and DELETE], default is [POST]
        default: "[POST]"
      - name: OW_ACTION_RAW
        description: flag to indicate raw HTTP handling, interpret and process an incoming HTTP body directly
        default: "false"
  outputs:
    resources:
      - name: builtImage
        type: image
  steps:
    - name: add-ow-env-to-dockerfile
      image: "gcr.io/kaniko-project/executor:debug"
      command:
      - /busybox/sh
      args:
      - -c
      - |
        cat <<EOF >> ${inputs.params.DOCKERFILE}
          ENV __OW_RUNTIME_DEBUG "${inputs.params.OW_RUNTIME_DEBUG}"
          ENV __OW_RUNTIME_PLATFORM "${inputs.params.OW_RUNTIME_PLATFORM}"
          ENV __OW_ACTION_NAME "${inputs.params.OW_ACTION_NAME}"
          ENV __OW_ACTION_CODE "${inputs.params.OW_ACTION_CODE}"
          ENV __OW_ACTION_MAIN "${inputs.params.OW_ACTION_MAIN}"
          ENV __OW_ACTION_BINARY "${inputs.params.OW_ACTION_BINARY}"
          ENV __OW_HTTP_METHODS "${inputs.params.OW_HTTP_METHODS}"
          ENV __OW_ACTION_RAW "${inputs.params.OW_ACTION_RAW}"
        EOF
    - name: adapt-dockerfile-to-tekton
      image: "gcr.io/kaniko-project/executor:debug"
      command:
      - sed
      args:
      - -i
      - -e
      - 's/COPY ./COPY .\/docker-source/g'
      - ${inputs.params.DOCKERFILE}
    - name: build-openwhisk-nodejs-runtime
      image: "gcr.io/kaniko-project/executor:latest"
      args: ["--destination=${inputs.params.TARGET_IMAGE_NAME}:${inputs.params.TARGET_IMAGE_TAG}", "--dockerfile=${inputs.params.DOCKERFILE}"]

When trying to build and push the image, am getting error:

conditions:
  - lastTransitionTime: "2020-09-24T07:33:11Z"
"step-add-ow-env-to-dockerfile" exited with code 2 (image: "docker-pullable://gcr.io/kaniko-project/executor@sha256:0f27b0674797b56db08010dff799c8926c4e9816454ca56cc7844df228c53485"); for logs run: kubectl -n default logs task-run-helloworld-pod-5bbkx -c step-add-ow-env-to-dockerfile
    reason: Failed
    status: "False"
    type: Succeeded

When checked the logs for error msg, I'm getting:

Error : /busybox/sh: syntax error: bad substitution

0

There are 0 answers