Issue with params using downstream plugin

Hello.

I’m using the downstream plugin, but I’m facing an issue with params.
If the trigger restarts a build that has that param already set, the new one is ignored.

This is the code of the trigger in .drone.yml:

  - name: trigger  
    image: plugins/downstream
    settings:
      server: https://mydrone.com
      token:
        from_secret: drone_token
      params:
        - DOWNSTREAM_IMAGE_VER=${DRONE_COMMIT_SHA:0:8}
      fork: false
      repositories:
        - org/myrepo@1.0

I think the issue is related to drone build restart:

$ drone build restart org/myrepo -p DOWNSTREAM_IMAGE_VER=test1 1
Number: 2
Status: pending
Event: push
[...]

In this case it works, DOWNSTREAM_IMAGE_VER=test1

$ drone build restart org/myrepo -p DOWNSTREAM_IMAGE_VER=test2 2
Number: 3
Status: pending
Event: push
[...]

In this case is not working the variable test2 is ignored, DOWNSTREAM_IMAGE_VER=test1

$ drone build restart org/myrepo -p DOWNSTREAM_IMAGE_VER=test3 1
Number: 4
Status: pending
Event: push
[...]

If i choose again the first build, it works: DOWNSTREAM_IMAGE_VER=test3

If I add more variables:

$ drone build restart org/myrepo -p DOWNSTREAM_IMAGE_VER=test4 ANOTHER_VARIABLE=myAwesomeValue 2
Number: 5
Status: pending
Event: push
[...]

In this case DOWNSTREAM_IMAGE_VER=test1 ANOTHER_VARIABLE=myAwesomeValue

mysql -e "use drone; select build_number,build_params from builds ORDER BY build_number desc LIMIT 3" -s
build_number    build_params
1    null
2    {"DOWNSTREAM_IMAGE_VER":"test1"}
3    {"DOWNSTREAM_IMAGE_VER":"test1"}
4    {"DOWNSTREAM_IMAGE_VER":"test3"}
5    {"DOWNSTREAM_IMAGE_VER":"test1","ANOTHER_VARIABLE":"myAwesomeValue"}

I’ve found this conversation Drone build restart does not pass parameters - Support - Drone and maybe because of that fix if a parameter is already in the build_params, the customer parameters injected by the cli is not used.

Related issues:

Hi,

I’m working with @Salvatore at the same issue.

For promoted builds it’s working (I’ve discovered this post Bug with environment variables of trigger downstream plugin - #4 by winrono Thanks @winrono )

I’ve opened a PR Override drone build restart parameters by asosso · Pull Request #3182 · harness/drone · GitHub