drone-webhook icon indicating copy to clipboard operation
drone-webhook copied to clipboard

build.started is not compatible with template datetime

Open puzzloholic opened this issue 6 years ago • 1 comments

Variable build.started is int64. It is incompatible with template datetime, which receive float64 and exactly 3 parameters

I try to do this

  - name: notification
    image: plugins/webhook
    settings:
      urls: https://chat.googleapis.com/v1/...
      content_type: application/json
      template: |
        {
          "text" : "Test Webhook\n```\nRepository Name: {{ repo.name }}\nBuild Number: {{ build.number }}\nBuild Status: {{ uppercase build.status }}\nBuild Author: {{ lowercase build.author }}\nBuild Author: {{ build.author }}\nBuild Event: {{ build.event }}\nBuild Commit: {{ truncate build.commit 8 }}\nBuild Branch: {{ build.branch }}\nBuild Link: {{ build.link }}\nBuild Started: {{ datetime build.started "3:04PM" "UTC+7" }}\nBuild Started: {{ datetime build.started }}\nDuration: {{ since build.started }}\n```"
        }
    when:
      status: [ success, failure ]

and receive error


2019/08/20 14:34:09 Evaluation error: Helper datetime called with argument 0 with type int64 but it should be float64
--
2 | Current node:
3 | String{Value:'UTC+7', Pos:415}

The param is not even optional, I cannot just put {{datetime build.started}}. It will output error like this


2019/08/20 14:41:27 Evaluation error: Helper 'datetime' called with wrong number of arguments, needed 3 but got 1
--
2 | Current node:
3 | Path{Original:'build.started', Pos:391}


puzzloholic avatar Aug 20 '19 15:08 puzzloholic

same problem

template:

{{datetime build.started "2006-01-02 15:04:05" "Asia/Shanghai"}}

error: image

Ansen avatar Dec 03 '21 04:12 Ansen