Che: Support for Environment Variables in Plugins and Editors

Created on 27 Aug 2019  路  13Comments  路  Source: eclipse/che

As developer I wish to use my internal nexus repository as a maven mirror for all the components of Che. Currently when I configure Che with Java project and I use MAVEN_MIRROR_URL env to do some mirror settings, the vscode java8 language server is still trying to reach to Maven central for the artefacts instead of local maven mirror (if one deployed)

aredevfilv1 kinenhancement severitP1 teaplatform

Most helpful comment

I think the idea is something like that

---
apiVersion: 1.0.0
metadata:
  generateName: java-maven-
projects:
  -
    name: console-java-simple
    source:
      type: git
      location: "https://github.com/che-samples/console-java-simple.git"
components:
  -
    type: chePlugin
    id: redhat/java/latest
    env:
       - name: MAVEN_MIRROR_URL 
          value: http://mirror.host/
  -
    type: dockerimage
    alias: maven
    image: quay.io/eclipse/che-java11-maven:nightly
    env:
      - name: MAVEN_CONFIG
        value: /home/user/.m2

All 13 comments

@metlos @l0rd @gorkem ^^

I don't understand what is being suggested here. The maven repo is controlled by the the maven settings.
Are you suggesting that the images running VS Code-Java are picking up the MAVEN_MIRROR_URL env variable and passing that on as configuration to VS Code Java?

I think the idea is something like that

---
apiVersion: 1.0.0
metadata:
  generateName: java-maven-
projects:
  -
    name: console-java-simple
    source:
      type: git
      location: "https://github.com/che-samples/console-java-simple.git"
components:
  -
    type: chePlugin
    id: redhat/java/latest
    env:
       - name: MAVEN_MIRROR_URL 
          value: http://mirror.host/
  -
    type: dockerimage
    alias: maven
    image: quay.io/eclipse/che-java11-maven:nightly
    env:
      - name: MAVEN_CONFIG
        value: /home/user/.m2

The idea is to support environment variables in chePlugin components.

But VSCode-Java would still not use that variable, so what's the point?

@tsmaeder - vscode does use the settings from the host which runs the plugin, so my point was to cascade the variable down to the host so that vscode can pick it up. IIUC the host in this case will be another container. correct me if am wrong

The local Maven repo is not configurable directly in m2e. You need to pass a custom Maven settings.xml path instead in java.configuration.maven.userSettings.

@fbricon - thats the settings I was looking for, may be we can make that configureable to Che like how we do the kubernetes references, that helps users adding the settings refernece devfile. does that make sense ?

@tsmaeder
In my case it can be used by @eclipse-che/theia-remote to set a container name to redirect runInTerminal request to a dev container.

After discussing this task with @l0rd @metlos @sleshchenko we decided to not to make things too complex that is why we want to populate environment variable to all containers that ChePlugin provides.

I have created a dedicated issue for maven settings https://github.com/eclipse/che/issues/14391. This current issue is about setting env variables for Che Plugins and is a pre-requisite for https://github.com/eclipse/che/issues/14391.

Also it would be useful to be able to configure env variables for Che editors as well. This way we could easily alter some editor configuration from devfile without requirement to override meta.yaml.

@kameshsampath @mmorhun The PR is just merged https://github.com/eclipse/che/pull/15435 and you should be able to use this feature as soon as you got newer Che images

Was this page helpful?
0 / 5 - 0 ratings