Wrong build arg format passed to docker when using plugin/docker

I’m using drone/drone:1.0.0-rc.3, docker 18.06.2-ce.

plugin/docker passed a json string to docker build_arg. However it seems docker doesn’t accept json. Is it a bug?

.drone.yml

kind: pipeline
name: default
steps:
  - name: 5.6-apache
    image: plugins/docker
    settings:
      username: maoxuner
      password:
        from_secret: docker_password
      context: apache
      dockerfile: apache/Dockerfile
      build_args:
        - PHP_TAG: 5.6-apache
      repo: maoxuner/php
      tags: 5.6-apache

Dockerfile

ARG PHP_TAG=latest
FROM php:${PHP_TAG}
RUN a2enmod rewrite ssl

Build Log

+ /usr/local/bin/docker build --rm=true -f apache/Dockerfile -t 31d867fbff049bff077da2cf4df5055454857bbb apache --pull=true --build-arg [{"PHP_TAG":"5.6-apache"}] --label org.label-schema.schema-version=1.0 --label org.label-schema.build-date=2019-02-18T08:43:28Z
Sending build context to Docker daemon 2.56kB
Step 1/10 : ARG PHP_TAG=latest
Step 2/10 : FROM php:${PHP_TAG}
latest: Pulling from library/php

...

/bin/sh: 1: a2enmod: not found
The command '/bin/sh -c a2enmod rewrite ssl' returned a non-zero code: 127
time="2019-02-18T08:45:00Z" level=fatal msg="exit status 127"

php:latest was pulled, not php:5.6-apache. Command a2enmod is not contained in the image, then build failed.

plugin/docker passed a json string to docker build_arg. However it seems docker doesn’t accept json. Is it a bug?

nope, the format in your example is wrong. The build_args parameter is an array. You need to make the following adjustments:

kind: pipeline
name: default
steps:
  - name: 5.6-apache
    image: plugins/docker
    settings:
      username: maoxuner
      password:
        from_secret: docker_password
      context: apache
      dockerfile: apache/Dockerfile
      build_args:
-       - PHP_TAG: 5.6-apache
+       - PHP_TAG=5.6-apache
      repo: maoxuner/php
      tags: 5.6-apache

Oh, you are right!
What a stupid mistake! It annoyed me for a long time.:triumph:
Sorry for wasting your time.