Browse Source

new: [drone-agent] implemented labels

Once labelled, you can use ``node: {label1: value1}`` in
``.drone.yml`` pipeline.
framadate
Valentin Lab 6 years ago
parent
commit
6c055be8a5
  1. 12
      drone-agent/hooks/init

12
drone-agent/hooks/init

@ -20,8 +20,17 @@ capacity="$(options-get capacity)" || true
name=${name:-"$(hostname)/$SERVICE_NAME"}
capacity=${capacity:-2}
## YYY should implement labels (see https://docs.drone.io/reference/agent/drone-runner-labels/)
service_def=$(get_compose_service_def "$SERVICE_NAME") || exit 1
labels_def=$(e "$service_def" | shyaml get-value options.labels) || true
[ "$labels_def" == None ] && labels_def=""
if [ "$labels_def" ]; then
labels=""
while read-0 label value; do
var+="$label:$value,"
done < <(printf "%s" "$labels_def" | shyaml key-values-0)
labels="${var::-1}"
fi
init-config-add "\
$MASTER_BASE_SERVICE_NAME:
@ -30,6 +39,7 @@ $MASTER_BASE_SERVICE_NAME:
DRONE_RPC_SECRET: $secret
DRONE_RUNNER_NAME: $name
DRONE_RUNNER_CAPACITY: $capacity
$([ "$labels" ] && echo "DRONE_RUNNER_LABELS: '$labels'")
volumes:
- /var/run/docker.sock:/var/run/docker.sock
"
Loading…
Cancel
Save