how do you pass Environment Variables to tasks triggered by Spring Cloud Data Flow UI

Viewed 250

I have a local setup for SCDF with docker-compose. I'm trying to understand how can I pass environment variables to a triggered task. I tried via the 'Deployer properties' but it doesn't seem to work. Ideally I would have liked to be able to set LOG4J2_APPENDER=PatternAppender in the UI... If its not possible via the UI, what other options do I have?

I tried to add under 'enviroment' in the docker-compose.yml (where there are other vars):

but it also didnt work:

dataflow-server:
    user: root
    image: springcloud/spring-cloud-dataflow-server:${DATAFLOW_VERSION:-2.9.1}${BP_JVM_VERSION:-}
    container_name: dataflow-server
    ports:
      - "9393:9393"
      - "1142:1142"
    environment:
      # Set CLOSECONTEXTENABLED=true to ensure that the CRT launcher is closed.
      - SPRING_CLOUD_DATAFLOW_APPLICATIONPROPERTIES_TASK_SPRING_CLOUD_TASK_CLOSECONTEXTENABLED=true
      - LOG4J2_APPENDER=PatternAppender
      - SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/dataflow
      - SPRING_DATASOURCE_USERNAME=root
      - SPRING_DATASOURCE_PASSWORD=rootpw
      - SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.mariadb.jdbc.Driver
      # (Optionally) authenticate the default Docker Hub access for the App Metadata access.
      #- SPRING_CLOUD_DATAFLOW_CONTAINER_REGISTRY_CONFIGURATIONS_DEFAULT_USER=${METADATA_DEFAULT_DOCKERHUB_USER}
      #- SPRING_CLOUD_DATAFLOW_CONTAINER_REGISTRY_CONFIGURATIONS_DEFAULT_SECRET=${MET
1 Answers

In your snippet, you're passing the environment variable SPRING_CLOUD_TASK_CLOSECONTEXTENABLED with the value true to all tasks.

The same should work for LOG4J2_APPENDER, i.e. add the environment variable

SPRING_CLOUD_DATAFLOW_APPLICATIONPROPERTIES_TASK_LOG4J2_APPENDER=PatternAppender

to the environment variables of the Dataflow server.

Setting the environment variable as an application property (not a deployer property) in the UI should have the same effect.

Related