Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 9. Example Workflow: Deploying Red Hat JBoss BRMS Application on Openshift with Webhooks Enabled for Automatic Application Updates
This workflow details how to configure Red Hat JBoss BRMS, GitHub, and OpenShift to have your configuration changes automatically push to OpenShift. This example covers:
- Setting up a forked GitHub repository
- Cloning the repository
- Creating a hook in JBoss Decision Server to automatically update the GitHub repository
- Modifying the example JBoss Decision Server rules
- Creating a Decision Service on OpenShift
- Improving OpenShift build times using Maven
- Integrating the Maven Proxy
- Configuring the OpenShift webhook to automatically update the decision service OpenShift whenever a code change occurs in the GitHub repository
- Testing the configured service and hooks
Make sure you are running Red Hat JBoss BRMS on your local machine.
9.1. Forking the Repository Copier lienLien copié sur presse-papiers!
- Visit the Decision Server example page while you are logged in to GitHub.
You are redirected to your new fork.
- Copy the HTTPS clone URL for your fork.
This Decision Server example receives a name, and if it matches the user name specified as master in the rules file, then the user is recognized and greeted as the master user. If the name does not match, then the user is recognized as an intruder.
9.2. Cloning the Repository Copier lienLien copié sur presse-papiers!
From the Red Hat JBoss BRMS workbench:
-
From the File Explorer, click Authoring
Administration. -
Click Repositories
Clone repository. -
Type the Repository Name
decision-services. - Select an Organizational Unit.
- Type in the HTTPS clone URL of your forked Git repository: https://github.com/<Your_Github_Username>/decisionserver.git
Click Clone.
Once cloned, the repository displays the commit history.
9.3. Creating a Hook to Automate GitHub Updates Copier lienLien copié sur presse-papiers!
To make Red Hat JBoss BRMS automatically update your GitHub repository any time a file in this project changes:
You must have SSH key access configured for GitHub before following these steps.
From the command line, navigate into the
/.niogitdirectory in the project you forked earlier:cd EAPHOME/bin/.niogit/decision-services.git
$ cd EAPHOME/bin/.niogit/decision-services.gitCopy to Clipboard Copied! Toggle word wrap Toggle overflow The path above is the default, which may differ depending on where the workbench has been configured to store its data. This location is set using the org.uberfire.nio.git.dir system property.
Set the remote URL for this project:
git remote set-url origin git@github.com:/decisionserver
$ git remote set-url origin git@github.com:/decisionserverCopy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate into the hooks directory:
cd hooks
$ cd hooksCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a simple post-commit file:
touch post-commit
$ touch post-commitCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the file and type the following:
#!/bin/sh git push origin master
#!/bin/sh git push origin masterCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Save your changes and exit the file.
Change the permissions on the file to allow Red Hat JBoss BRMS the access it requires:
chmod 777 post-commit
$ chmod 777 post-commitCopy to Clipboard Copied! Toggle word wrap Toggle overflow The hook is now configured, meaning that any change to the files in this Red Hat JBoss BRMS project will automatically update your forked decisionserver GitHub repository.
9.4. Modifying the Example Decision Server Rules Copier lienLien copié sur presse-papiers!
From the Red Hat JBoss BRMS workbench:
-
Click Authoring
Project authoring. Under DRL, click to load the HelloRules.drl file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Modify the lines with
johnby replacing them with your user name. Click Save, type a check in comment, and click Save again.
The hook you created earlier will automatically update your forked GitHub repository with these saved changes.
9.5. Creating a Decision Service on OpenShift Copier lienLien copié sur presse-papiers!
From the OpenShift web console:
- Log in using the username and password recommended to you by your administrator.
- To create a new project, click New Project.
- Type a unique name, display name, and description for the new project.
Click Create.
The web console’s welcome screen loads.
- Click Add to Project.
-
In the Filter by keyword field, start typing
decisionto see the available xPaaS templates related to Decision Server. - Click the decisionserver63-basic-s2i template.
- In the Parameters section, change the KIE_SERVER_PASSWORD to the password to access the KIE Server REST or JMS interface.
Change the SOURCE_REPOSITORY_URL to the Git source URI for your forked repository. For example:
https://github.com/<your_github_username>/decisionserver.git
https://github.com/<your_github_username>/decisionserver.gitCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Change the SOURCE_REPOSITORY_REF to
master. -
Change the CONTEXT_DIR to
greeting. - Scroll to the bottom of the page and click Create.
While your application builds, you can click View Log from the Overview page to see the build progress.
9.6. Improving Build Time Using Maven Copier lienLien copié sur presse-papiers!
Follow the details in this OpenShift blog post to configure the Maven proxy, which improves the build times of java builds on OpenShift.
9.7. Integrating the Maven Proxy Copier lienLien copié sur presse-papiers!
To change the build configuration so that it uses the Maven proxy, complete the following from the OpenShift web console:
-
Click Browse
Builds <your_application> - Click the three vertical dots next to Start Build and then click Edit (Raw).
Add the MAVEN_MIRROR_URL environment variable below the KIE_CONTAINER_DEPLOYMENT variable:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The value for MAVEN_MIRROR_URL can be found in Maven by viewing the repositories, then copying the path for the Public Repositories group.
- Click Save.
- Click the Configuration tab of your build to verify that MAVEN_MIRROR_URL is actively listed under Environment Variables.
Now that you have Maven configured for this OpenShift project, the build process will be shorter for all future builds. This is because subsequent builds only need to download updated files, which are then combined with the previously loaded files.
9.8. Test the Service Copier lienLien copié sur presse-papiers!
After integrating the Maven proxy, you can test that service is working and see how quickly the build process completes compared to previous builds. From the OpenShift web console:
-
Click Browse
Builds <your_application> - Click Start Build.
- In the list at the bottom of the screen, click the new build you just started.
- Click the Logs tab, then click Follow.
Verify that the new build is using the new Maven proxy to download locally by finding the line in the log that references
Downloading. For example:I0130 12:32:25.664594 1 sti.go:492] Downloading: http://nexus-ci.cloudapps.openshift.com/content/groups/public/org/kie/kie-maven-plugin/6.3.0.Final-redhat-5/kie-maven-plugin-6.3.0.Final-redhat-5.pom
I0130 12:32:25.664594 1 sti.go:492] Downloading: http://nexus-ci.cloudapps.openshift.com/content/groups/public/org/kie/kie-maven-plugin/6.3.0.Final-redhat-5/kie-maven-plugin-6.3.0.Final-redhat-5.pomCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
When the build is complete, you can check the new build time against the previous build by clicking Browse
Builds <your_application> and viewing the summary. The newest build will be considerably shorter with the Maven proxy in use. -
Click Overview to see the status of the pod. It displays a
Not Readystatus while it is checked with readiness probes. -
Click Browse
Pods to follow its progress. The status of the Containers Ready column will change to 1/1when the pod has passed the readiness probes.
9.9. Configure the OpenShift Webhook Copier lienLien copié sur presse-papiers!
From the OpenShift web console:
- Click the Browse tab, then click Builds.
- Click your build name, then click the Configuration tab.
- Click the copy icon next to GitHub webhook URL to copy your webhook payload URL.
- Navigate to your forked repository on GitHub, then click Settings.
- Click Webhooks & Services.
- Click Add webhook.
- Paste your webhook URL into the Payload URL field.
- Click Disable SSL verification, then confirm it in the pop-up window.
- Click Add webhook to save.
Github pings the OpenShift server to ensure communication is successful. A green check mark next to the webhook URL signifies that it is configured correctly. Hover your cursor over the check mark to view the status of the last ping.
The next time you push a code change to your forked repository, your application will automatically rebuild.
9.10. Testing the Configured Hooks Copier lienLien copié sur presse-papiers!
From the Red Hat JBoss BRMS workbench:
Load the HelloRules.drl file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Modify the String salutation line by changing
At your service my masterto something else. - Click Save, type a check-in comment, and click Save again.
The hook that you created earlier updates your forked GitHub repository, and then the GitHub webhook triggers a new build in OpenShift.
With this configuration, you need only save your configuration changes on the Red Hat JBoss BRMS workbench, and the rest of the process is completely automated.