Develop an Existing OpenShift Application with JBoss Developer Studio 9.x

Updated -

OpenShift Tools enables you to import existing OpenShift applications into the IDE so that you can take advantage of the IDE features in further developing your applications. As illustrated in this article, during the import process you can configure the IDE for easy republishing to OpenShift.

The instructions here demonstrate how to complete the following tasks:

  1. Import an Existing OpenShift Application

  2. Modify the Application Source Code

  3. Republish the Modified Application

  4. View the Modified Application

1. Import an Existing OpenShift Application

Applications associated with your OpenShift account(s) are listed in the OpenShift Explorer view. The source code for these applications can be individually imported into the IDE using the OpenShift Tools Import OpenShift Application wizard.

To import an existing OpenShift application as a new project in the existing IDE workspace, complete the following steps:

  1. In the OpenShift Explorer view, ensure your OpenShift connection is listed or click the Connection icon Connection icon and complete your OpenShift account details to create a new connection.

  2. In the OpenShift Explorer view, expand the connection and domain to locate the application you want to import.

  3. Right-click {application name} and click Import Application.

  4. Complete the fields about the application to be imported as follows:

    • Ensure that Use my existing OpenShift application is selected.

    • Ensure that the name of the application you want to import is listed. If this is not the case, type the name of the application or click Browse to select the application.

      Existing OpenShift Application Information Provided

  5. Click Next.

  6. Complete the fields about the corresponding new workspace project as follows:

    • Ensure the Create a new project check box is selected.

    • Ensure the Create and set up a server adapter for easy publishing check box is selected.

  7. Click Next.

  8. Ensure the location in the Git Clone Destination field corresponds to where you want to make a local copy of the OpenShift application Git repository.

  9. Ensure a public SSH key is uploaded to OpenShift and private key location is specified in the IDE preferences by clicking SSH Keys Wizard and reviewing the information.

  10. Click Finish.

If you are prompted that the authenticity of the host cannot be established and asked whether you want to continue connecting, ensure that the host name matches that of your application and domain and click Yes.

When the import process is complete, the project is listed in the Project Explorer view and a server adapter is listed for the application in the Servers view.

OpenShift Tools makes a number of small changes to the application source code on import. It adds several IDE-specific files to the project and modifies the .gitignore file so that you are not prompted about these files each time you commit project changes to the Git repository.

2. Modify the Application Source Code

The files contained in your project depend on the type of project that you have imported. Here a common OpenShift application file, index.html, is changed as an example of modifying the project source code. You can opt to change this file or another file of your project.

To modify the index.html file, complete the following steps:

  1. In the Project Explorer view, expand {project name} > src > main > webapp.

  2. Double-click index.html to open it in the JBoss Tools HTML Editor.

  3. After the opening <body> tag add the following line:

    <h1>This is a change made to my OpenShift app from the IDE.</h1>
    
  4. Save the index.html file by pressing Ctrl+S (or Cmd+S).

Note that in the Project Explorer view, index.html has > prepended to show that the source code has changed since the last Git commit.

3. Republish the Modified Application

You must commit and push any changes you have made to the project source code and then republish the application before you can see changes reflected in the OpenShift application. As an example of committing and pushing source code changes to the OpenShift application repository and republishing the application, here the index.html file changed earlier is used. You can opt to use the project file that you changed earlier.

To commit and push the index.html changes and republish the application to OpenShift, complete the following steps:

  1. In the Servers view, right-click {application name} at OpenShift and click Publish. Or you can drag the {project_name} from the Project Explorer view and drop it on the server adapter in the Servers view.

  2. Complete the fields about the project changes to commit and push to the OpenShift application Git repository as follows:

    • In the Commit message field, type the following message

      Added new heading in body of index.html
      
    • In the table of files, ensure the index.html file is selected.

      Commit Message Provided and Changed Project File Selected

  3. Click Commit and Publish.

The republishing process can take some time. When the Console view shows Deployment completed with status: success, the republishing process is complete.

4. View the Modified Application

After the modified application is republished, you can view the live updated version at the OpenShift application URL.

To view the modified OpenShift application in the IDE default web browser, complete the following steps:

  1. In the OpenShift Explorer view, expand the connection and the domain.

  2. Right-click {application name} and click Show In > Web Browser.

Your modified and republished OpenShift application is displayed in the IDE default web browser.

Did You Know?

  • On the first occasion that you republish your application to OpenShift, you may be prompted to provide a username and email address for use by Git. The IDE looks for a default Git configuration file on your system from which to obtain this information and if the IDE cannot find the file it prompts you to provide the values. You can specify the location of your system Git configuration file in the IDE Preferences, under Team > Git Configuration.

  • You can review the progress of republishing applications to OpenShift in the Console view.

  • You can also open the OpenShift application in a web browser from the Servers view by right-clicking {application name} at OpenShift and clicking Show In > Web Browser.

  • You can change the IDE default web browser to be either the IDE internal web browser, BrowserSim (when installed) or an external web browser. Click Window > Web Browser and select from the available web browser options or click Window > Preferences > General > Web Browser to extend the list of available external web browsers.