Skip to main content

Version: 23.10

Jenkins CI Example

Jenkins is a popular CI tool for automating tasks related to building, testing and deploying software.

Journey SDK Dependency

In order to build the Home Loan application, it needs to declare a dependency to Journey SDK libraries. There are several approaches you can choose from.

  • Option 1 (Recommended) Unzip the SDK on your file system and use Ant's -lib option to point to the folder with the libraries; for example, ant -lib "SDK_HOME/lib". In Jenkins you may add the SDK_HOME environment variable and refer to it in your Ant invokes.

    alt-text

  • Option 2 Add SDK libraries to the project structure, and then use Ant's -lib option to point to the folder containing the libraries.

  • Option 3 Add the SDK libraries in the Ant lib folder.

  • Option 4 Add all the libraries on the CLASSPATH environment variable.

In the following example, it is assumed that the SDK is unpacked somewhere on your file system, so we have to point Ant to where the SDK library folder is by using Ant's -lib optionl; for example, ant -lib "SDK_HOME/lib".

Home Loan Example

Project builds are handled via jobs in Jenkins. Follow these steps to setup a Jenkins CI job for the Home Loan application.

info

In this example, we refer to the SDK_HOME environment variable using the Windows syntax $SDK_HOME.

On a Unix-based system, use %SDK_HOME% instead.

  1. Select New Item and enter a name for the job, then select Freestyle project and press OK.

    alt-text

  2. Enter a description for the job and configure how many old jobs should be retained.

    alt-text

  3. Configure how to retrieve the source code; that is, how to checkout the Application Package (Forms, Functions, Tests). For example, if you're using Git, enter the URL to the Git repository. If the repository is not public, you may also need to configure the credentials.

    alt-text

  4. Specify when and how your build should be triggered. The following example polls the Git repository every 20 minutes. It triggers a build, if something has changed in the repository.

    alt-text

  5. Add an 'Invoke Ant' step with target app-test to execute any local unit tests and build the Application Package. Use the -lib option to pass Journey SDK's libraries to Ant.

    alt-text

  6. Add an 'Invoke Ant' step with target app-deploy to deploy the Application Package to your Journey Manager (JM) Test server. Specify the required JM server details (credentials may be stored/extracted with some Jenkins Credential Plugins). Use the -lib option to pass Journey SDK's libraries to Ant.

    alt-text

  7. You may want to add a post-build action step to keep the build artifacts.

    alt-text

  8. Click Save to finish the job definition.

  9. Click Build Now on the job page to verify that the job works as expected.

    alt-text

Sample Build Log

Here is sample of the logged output from a successful build, test and deployment of the application package.

Started by user Avoka Dev
Building in workspace D:\Jenkins\workspace\home-loan
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config
> git.exe --version # timeout=10
> git.exe fetch
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision fc9cfa105c5adb303ddef7d98008d47c5cda4843 (refs/remotes/origin/master)
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f fc9cfa105c5adb303ddef7d98008d47c5cda4843
Commit message: "Add some test"
> git.exe rev-list fc9cfa105c5adb303ddef7d98008d47c5cda4843 # timeout=10
[home-loan] $ cmd.exe /C "ant.bat -Dmanager.username=username -Dmanager.password=password -Dmanager.url=https://mycompany.com/manager/ -Dmanager.clientCode=maguire -lib "/data/tools/transact-sdk-18.5.0/lib" app-deploy && exit %%ERRORLEVEL%%"
Buildfile: D:\Jenkins\workspace\home-loan\build.xml
svc-imports:
[svc-imports] Completed Service Imports
svc-typecheck:
[svc-typecheck] Completed Type Check
clean:
[delete] Deleting directory D:\Jenkins\workspace\home-loan\target
svc-package:
[svc-package] Created service archive: D:\Jenkins\workspace\home-loan\target\services-v0.1.0.zip
svc-test:
[svc-test] DDS - v0.1.0 : unit test succeeded in 1,604 ms
[svc-test] 12:13:10,753 INFO {
[svc-test] "address": {
[svc-test] "firstLine": "123 Wall Street"
[svc-test] }
[svc-test] }
[svc-test]
[svc-test] 1 Service Unit Tests completed in 5,186 ms
app-package:
[app-package] Created application package archive: D:\Jenkins\workspace\home-loan\target\app-home-loan-v0.1.0.zip
app-deploy:
[app-deploy] Http client: created.
[app-deploy] Request: POST https://..../secure/rest/application-package/v1/maguire HTTP/1.1
[app-deploy] Response: HTTP/1.1 200 OK
[app-deploy] Response: {
[app-deploy] "archiveName": "app-home-loan-v0.1.0.zip",
[app-deploy] "importMessage": "Application package named 'Home Loan' for organization 'maguire' was imported.",
[app-deploy] "importStatus": "Completed",
[app-deploy] "importTime": "2018-01-12T12:13+1100"
[app-deploy] }
BUILD SUCCESSFUL
Total time: 15 seconds
Finished: SUCCESS