How to quickly deploy a VS Code extension on Eclipse Che

Try a custom VS Code extension

Florent Benoit
Eclipse Che Blog
4 min readJul 24, 2020

--

Introduction

Eclipse Che is supporting VS Code extensions in its IDE.

Each workspace can have its own set of plug-ins. This definition of plug-ins is stored inside a devfile.yamlfile containing as well the list of projects to clone.

From the dashboard, there is a list of plug-ins that can be enabled on a given workspace.

toggle plug-ins

When a plug-in is enabled, a new entry is added in the devfile.yaml file.

For example, enabling AsciiDoc plug-in is adding the following snippet in my devfile.

It’s easy but what if the plug-in that I want to try is not in the default Eclipse Che plug-in registry ?

Here come multiple ideas. One of them is to fork the current plug-in-registry repository, rebuild the docker image, deploy it and use this registry. It’s very powerful for ‘in-house’ use-cases, etc but it might be a big effort at first.

Setup configuration

Let’s try to make it very simple by just using Github and its gist service.

Go on https://gist.github.com/ and create a README.md file saying for example that : Try Bracket Pair Colorizer extension in Eclipse Che

It’s because I want to try https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer with its 3M of downloads !

And click on Create secret gist button

You might not know, but behind a gist, there is a git repository. Let’s clone this repository by using the URL from the navbar.

Git clone command will look like:

In my case it was

then we enter into this cloned directory

Create the devfile and plug-ins definition

First, download the plug-in from the VS Code marketplace https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer or from its github page https://github.com/CoenraadS/BracketPair/releases and store the file in the cloned directory

Then, we need to add a definition of this plug-in through a yaml file.

Let’s create this file in the cloned directory

Two remarks there:

  • This extension seems to only require nodejs runtime so in the yaml definition I didn’t specified a custom runtime image.
  • I’m using {{REPOSITORY}} in URL to later compute this link to avoid to search the public URL of the file for now.

note: in the spec section, we can specify a custom runtime image, memory limit and some extra volumes, but for the use-case of this simple extension, it was not required.

So, plugin.vsixfile is there, plugin.yaml file is there and we only need our workspace definition: devfile.yaml

You could have taken any other devfile definition., the only important information from this devfile are the lines

It means that we’ll add a custom plug-in using an external reference vs just an id pointing to a definition inside the default plug-in registry.

To sum up, we have 4 files in the current git directory:

We will need to commit the files to our repository, but before, we’ll add a pre-commit hook to update {{REPOSITORY}} variable to the public external raw gist link.

Pre-commit hook is in place, it’s time to commit our files

git status output

…commit the files…

… and push the files to the main branch

By going back to the gist website, we can see that all links have been updated with the correct public URL.

Now it’s time to experiment our devfile by entering the command to check that online !

or if you only want the link

I can now code with nice brackets :-)

--

--

Florent Benoit
Eclipse Che Blog

Working on Eclipse Che and Red Hat Code Ready Workspaces Twitter: @florentbenoit