⬆️ ⬇️

Continuous integration in the cloud

Recently, developers are increasingly turning to us with requests to implement CI in Jelastic. Why do we need continuous integration? As a rule, in a project where developers work independently on different parts, the integration stage is final and rather laborious, and therefore requires additional time. The transition to continuous integration allows reducing this laboriousness, as well as detecting and eliminating errors in advance, before they have taken root yet and have not grown into a more serious problem. Yes indeed, if you carry out quality control throughout the entire development process, you can save both time, money, and effort, while improving quality. This approach is especially useful for large projects involving a large number of developers.



Today we will show how you can implement continuous integration in the Jelastic cloud with a simple example using Jenkins .



Step-by-step instruction:

')

1. Create an environment in Jelastic and deploy Jenkins in it (or deploy it locally on your computer). You can deploy your application in the same environment or create another one separately.



2. Now you need to slightly modify the files of your project: settings.xml and pom.xml in order to use the Maven plugin for Jelastic.



Register the profile tag in the settings.xml file and specify your login and password for the Jelastic dashboard:

< profile >

< id > jelastic </ id >

< activation >

< activeByDefault > true </ activeByDefault >

</ activation >

< properties >

< jelastic.username > [insert your Jelastic username] </ jelastic.username >

< jelastic.password > [insert your Jelastic password] </ jelastic.password >

</ properties >

</ profile >


Now add the Plugin Repository section in pom.xml , specify the path to the repository in which the Jelastic Maven plugin is stored:

< pluginRepositories >

< pluginRepository >

< id > sonatype-oss-public </ id >

< url > https : //oss.sonatype.org/content/groups/public </ url >

< releases >

< enabled > true </ enabled >

</ releases >

< snapshots >

< enabled > true </ enabled >

</ snapshots >

</ pluginRepository >

</ pluginRepositories >


Also in pom.xml, register the section for plugins to which you need to add a plug-in to automatically deploy the application in the environment created earlier:

< plugins >

<! - ... ->

< plugin >

< groupId > com.jelastic </ groupId >

< artifactId > jelastic-maven-plugin </ artifactId >

< version > 1.7-SNAPSHOT </ version >

< configuration >

< email > $ {jelastic.username} </ email >

< password > $ {jelastic.password} </ password >

< context > < ! - insert your context path for ROOT for default-- > </ context >

< environment > < ! - insert your environment name-- > </ environment >

< api_hoster > < ! - default value "api.jelastic.com" - > </ api_hoster >

</ configuration >

</ plugin >

<! - ... ->

</ plugins >


In the <api_hoster> tag, specify the appropriate host API .



3. Open Jenkins and Browser and install Maven automatically.



image



4. Create a new project.



5. On the Configuration page, in the Source Code Management section, select Subversion and enter the URL to your repository.

You can also poll your system for changes after a certain period of time. To do this, fill in the appropriate field.



6. In the Build section, specify Root pom ( pom.xml ). In the Goals and Options field, enter the following line:



clean install jelastic: deploy



This will allow you to shut down your application in Jelastic automatically.



image



Well that's all! Now just click Build now and your project will be automatically assembled and deployed in the cloud. And Jenkins will poll the system for changes made according to the time period you specified.



We will be very grateful for feedback and suggestions for improving this functionality.

Source: https://habr.com/ru/post/148893/



All Articles