2

In order to track the configuration of our Jelastic hosting environment, I would like to version it in a git repository. The repository is supposed to be private and contain several different branches with different versions (such as master, abc123, v1.1).

My first try was to create a private github repo containing:

  • A manifest.json, to describe the environment's topology
  • A set of configuration files, such as webserver configuration, …

Now, I wonder:

A) How can I import an environment from a private git(hub) repository into Jelastic? Can I use the Dashboard Import URL feature to do so? Or do I have to use the CLI?

B) How can I make sure that the manifest.json refers to the configuration file of the same version as the manifest.json itself? How do I pass the credentials for Jelastic to be able to retrieve the configuration files?

I had a look at one of the Jelastic sample environments: https://github.com/jelastic-jps/basic-examples/blob/master/automatic-environment-migration-after-cloning/manifest.jps

There: The configuration files (e.g. alfresco-global.properties) are loaded from a public github repository. Therefore no credentials are required, neither for the manifest.json, nor for the configuration files. Additionally, the configuration files will always be loaded from the master branch.

In contrast,

  • I would like the repository to be private
  • I would like to make sure that version abc123 of the manifest.json will always be deployed with version abc123 of the configuration files.

Is this possible at all? And is there a best-practice?

SomeBdyElse
  • 427
  • 1
  • 4
  • 11

2 Answers2

3

How can I import an environment from a private git(hub) repository into Jelastic? Can I use the Dashboard Import URL feature to do so? Or do I have to use the CLI?

For this, We need to use the webhook functionality provided by any decent GIT SCM. Check generate token link.

sample

Within the opened installation window, specify the following data:

  • Git Repo Url - HTTPS link to your application repo
  • Branch - a project branch to be used
  • User- your Git account login
  • Token - personal Git access token for webhook generation (can be created within GitHub/GitLab account settings)
  • Environment name - target environment your application should be deployed to
  • Nodes - application server name (is fetched automatically upon selecting the environment)

After success installation, all the further changes, committed to a source repository, will be automatically delivered to your environment inside Jelastic Cloud.

How can I make sure that the manifest.json refers to the configuration file of the same version as the manifest.json itself? How do I pass the credentials for Jelastic to be able to retrieve the configuration files?

As we are using Jelastic, We just can use the Jelastic provided functionalities. Currently you can set the branch name, so you could have :

  • As many repositories as manifest.jps you have
  • As many branches as manifest.jps you have

Is there a best-practice?

Bet practice could be use As many repositories as manifest.jps you have and use git flow to versioning:

git-flow

Master as the stable and production version of manifest.jps. Any change of this manifest.jps must be audited or reviewed by a team in order to prevent mistakes. Also you can use tags to versioning this manifest.jps and easy revert master to any tag.

References

JRichardsz
  • 14,356
  • 6
  • 59
  • 94
  • I already had a look at https://github.com/jelastic-jps/git-push-deploy , but it does not seem to fit my need. As far as I understand, the "Git-Push-Deploy Add-On" can be used to deploy application code to an existing environment. In my use case, I would like to recreate the environment itself. (Import of a manifest.json file to create an environment). – SomeBdyElse Jan 03 '19 at 16:14
  • Do you want an empty environment? – JRichardsz Jan 03 '19 at 22:50
  • I would like to be able to recreate the environment, including the application. This question is only about the environment part though, as we already have tools to deploy the application into an existing environment. – SomeBdyElse Jan 06 '19 at 18:27
2

A) How can I import an environment from a private git(hub) repository into Jelastic? Can I use the Dashboard Import URL feature to do so? Or do I have to use the CLI?

B) How can I make sure that the manifest.json refers to the configuration file of the same version as the manifest.json itself? How do I pass the credentials for Jelastic to be able to retrieve the configuration files?

To import an environment from a private Github repository into Jelastic, you should import manifest file URL with token through Dashboard Import feature.

To do this, you need:

Example for manifest file:

type: install
name: Test Private Repo

baseUrl: https://raw.githubusercontent.com/{user}/{repo}/{branch}
settings: 
 fields: 
- name: token
  caption: Token
  type: string
  default: 

globals: 
  token: ${settings.token}

description: README.md?access_token=${globals.token}

onInstall:
  # Shell script by URL
  - cmd: script.sh?access_token=${globals.token}

  # Base URL inside shell script
  - cmd: |
      wget '${baseUrl}/script.sh?access_token=${globals.token}' -O script.sh
      chmod +x script.sh
      ./script.sh

  # Javascript by URL
  - script: script.js?access_token=${globals.token}  
Virtuozzo
  • 1,993
  • 1
  • 10
  • 13
  • Thank you for your quick reaction. The above manifest file would solve the issue. Unfortunately, adding a **personal access token** to the source code of the application is not an option for me. Is there any other way that the import dialog will accept credentials (such as BasicAuth credentials) to be used for fetching the manifest.json and all subsequent files? Would a dynamic baseUrl help? Example import URL (fine in curl): `https://$token:@raw.githubusercontent.com/repo/$version/manifest.json` Derived baseUrl: `https://$token:@raw.githubusercontent.com/repo/$version/` – SomeBdyElse Jan 06 '19 at 18:16
  • 1
    We slightly changed the example in the answer, now you can use the token without inserting it into the manifest. HTTP Basic Auth support will be available in a future release. – Virtuozzo Jan 09 '19 at 10:43
  • Great, thank you! I will have a look if that works. I will also check if I can leave out the static baseURL, so the import function will automatically pick the right version for the files. – SomeBdyElse Jan 11 '19 at 07:40
  • does not seem to work on Jelastic v6.0.2 and github free plan – Laurent Michel Apr 13 '21 at 14:50