GitLab CI Tutorial

   PlatformApplicable to all products in Temenos Journey Manager.

GitLabGitLab is a web-based Git-repository manager with wiki and issue-tracking features, using an open-source license, developed by GitLab Inc. is a version control system supporting Continuous Integration. This article explains you how to store content GitLab using two distinct strategies: a minimalist source-only method, and a complete build environment method.

Prerequisites

This tutorial assumes you have already done the following:

  • Obtained GitLab server login access with enough privileges to create projects. Ask your administrator to create a project with the .gitignore file.
  • Installed Git client. You can download a Windows client at https://git-scm.com/download/win
  • Completed the Jenkins CI tutorial

Objectives

  1. Create a GitLab project on a GitLab server.
  2. Create a .gitignore file in the project to ignore all but the src/* folder in our project, providing the minimalist approach.
  3. Initialize a local GitLab repository in an existing Jenkins CI workspace containing the Transact Fluent SDK.
  4. Clone the GitLab project to the local repository.
  5. Check-in the local artifacts generated by the Transact Fluent SDK
  6. Hook the Jenkins CI project to the GitLab project.
  7. Run the Jenkins CI project to pull from GitLab and execute the CI pipeline.
  8. Alter the .gitignore file to add all files to GibLab, except build.properties, providing the complete approach.
  9. Push all files to GitLab.
  10. Create a build.properties-TEMPLATE file, so the GitLab project contains a template for new build.properties files.
  11. Push the new template file to GitLab.

Minimal Version Control

  1. Login to GitLab and click New project.
  2. Enter a name and click Create project.
  3. Click on the .gitignore link.
  4. Enter the following values, which will cause commits to ignore all files except those in the src folder, and click Commit changes.
  5. Click the project name part of the breadcrumb.
  6. You will see the file has been committed.
  7. Click on the project name breadcrumb in the header.
  8. Copy the project ssh URL to the clipboard to use in the following commands
  9. Open a command prompt, type cd to the CI Workspace folder, then type git init and click Enter to establish the current directory as a local Git repository
  10. git init
  11. git remote add origin and type your Git project URL
  12. git remote add origin <your Git project URL>
  13. git pull origin master
  14. git pull origin master
  15. git add .
  16. git add .
  17. git commit -m "Initial commit"
  18. git commit -m "Initial commit"
  19. git push -u origin master. The local files that match the .gitignore rules have now been stored in the GitLab project
  20. git push -u origin master
  21. Refresh the GItLab project page and you will see the src folder and its children are now stored in the project.
  22. Click Configure link to configure the Jenkins project to poll changes from GitLab and trigger a build, if there are any changes found.
  23. Scroll down to Source Code Management and select the Git radio button.
  24. Enter the GitLab project URL and tab out of the field - red credential error messages will appear. Click Add and select Jenkins to add a new credential
  25. Select the Kind of credential to add. Enter additional fields according to the credential Kind chosen - the dialog will vary. Click Add
  26. Back on the Source Code Management block, select the newly added credential from the dropdown.
  27. The GitLab credentials should validate and the red errors disappear

  28. Scroll down to Build Triggers and click Poll SCM
  29. Enter H/2 * * * * in the Schedule text area to poll GitLab every 2 minutes and click Save.
  30. Enter these commands from a CMD prompt to change a local file and check it into GitLab.
  31. 
    					cd "C:\Development\Jenkins\CI Workspace"
    					edit src\services\helloworld\service-help.html
    					git add .
    					git commit -m "Triggering Jenkins Build"
    					git push -u origin master
    			
  32. Within few minutes, a new build will be triggered, and you will seethe build output in the Build History section.
  33. The build is complete now.

Complete Version Control

At this point, you will have a GitLab project populated only with the files you have created locally. It will not contain the Transact Fluent SDK files, because we ignored them with the rules we created in the .gitignore file.This minimalist method does save space in the GitLab repository, but it may not be ideal in terms of deploying to a new server. Any new server would need to have the Transact Fluent SDK installed on it before pulling the GItLab project.

We can convert the minimalist approach to a complete approach simply by changing the .gitignore file, adding additional files and committing to the GitLab project. Now, when the project is pulled from GitLab, the complete Transact Fluent SDK comes with it, so it can be deployed on a new server and it is ready to go.

We want to add all files from our local folders to GitLab, but we want to exclude the build.properties file, because it contains sensitive passwords.

  1. Edit the contents of your local .gitignore file, which should include /build.properties now.
  2. Add new files to GitLab by entering the following commands:
  3. 
    git add .
    git commit -m "Adding all files except build.properties"
    git push -u origin master
    
  4. Check the git commit command output.
  5. Now, we have all files in the GitLab project, except build.properties. As we don't know what goes in the build.properties file, we should add a build.properties-TEMPLATE file that contains the default build.properties file from the Transact Fluent SDK. Extract the build.properties from the zipped Transact Fluent SDK file, and rename it to the build.properties-TEMPLATE.
  6. 
    git add .
    git commit -m "Adding build.properties-TEMPLATE"
    git push -u origin master
    
  7. Now, our GitLab project contains all of the Transact Fluent SDK files, except for our customized build.properties with the sensitive passwords, but it does have a build.properties-TEMPLATE file, so a new user can use it to construct their own build.properties file.
  8. Your GitLab project should now look like this.

Next, learn about Jenkins CI.