Git On IBMi 🚤🚤🚤

Disclaimer: Git and GitHub are related but not the same.
Git is software used for version control. GitHub is a company using Git software to provide GUI on git and various other features.

What is git?

Git is a free and open source distributed version control system designed to handle everything from small to huge projects with speed and efficiency. The Git feature that really makes it stand apart from nearly every other SCM out there is its branching model. More on git can be read here Git Docs

Git runs in the PASE environment in the Power system and can be used for version control by keeping sources in IFS and other stream files.

How to set up git on your machine?

You need the yum package manager first. Follow this
Using SSH login into your system and set the correct path if not done already via .profile PATH=/QOpenSys/pkgs/bin:$PATH && export PATH, this helps your shell in locating the open source binaries.
Preferentially use BASH shell as it has a lot of friendly features.
If you have yum then do a yum install git command to install git.

Get started with Git on IBMi 🤟

pwd to check the present working directory.
If you don’t want to use the pwd for git use cd /path/to/direcory to native to the desired path.
mkdir dir-name command to create a new directory for version control, IFS is case sensitive in most places so let’s pretend that to be the default feature to avoid confusion.
cd dir-name to get into the directory.
git init command will initialize the directory as a git repo, and you can see a new hidden file named .git is created. This file will have all the source control information so never ever delete this.
touch mypgm.rpgle command creates a new file mypgm.rpgle.
Make some changes in mypgm.rpgle and save those changes.
Do a git status command which tells you that there is a file name mypgm.rpgle which is not being tracked by git so you will have to tell git to track this file.
git add mypgm.rpgle adds mypgm.rpgle to the staging area(where changes will be tracked).
git add . command (notice the full stop) is to add all the untracked files in the working directory, this saves time if you have added a lot of files and they all need to be tracked.
git commit -m “my comments for code changes ” command moves mypgm.rpgle to the local repository. The comments after -m in quotes are very important since they will tell you or other developers in the future why this commit was made, which is sort of documentation but in brief.
When a git initialization is done a branch named master is created by default which can be checked using git branch -a.

🥳 There is more to git but these are the basic starting point. Usually, organizations also use source storage services like GitHub and BitBucket as central repositories to store their source and manage it easily. This will be covered in a later blog as first you should familiarize yourself with the initial steps first and get used to using git. There are tons of information already available on the web for git which can be referred for advanced learning.

In my next blog, I will be introducing a small toll to help in enabling native source control easily. Thank you for reading this far. 😀

SUBSCRIBE to the newsletter.

PASE up your work 🚀🚀🚀

Introduction

Portable Application Solutions Environment for i (PASE for i) as you may know is used to run open source solutions on IBMi. As per IBM document PASE for i also provides industry-standard and defacto-standard shells and utilities that provide you with a powerful scripting environment. This comes in very handy because a lot of open-source tools make use of scripting language and command-line tools.

Over the past few years, we have seen a lot of buzz around modernization on IBMi well it’s no more a buzz but an ongoing process where many shops have modernized their system and some are in the process of doing so. Modernization of IBMi will be a continuous process for coming many years. Several vendors are supporting this change, and IBM is also actively supporting modernization on the i by bringing support for more and more applications on the i. Read this document for more details on IBM’s support for open-source software click here.

Largely all these modernization processes are centered around open source applications, like using Nodejs for APIs, JavaScript and PHP for web development, Jenkins and GitHub for deployments, and many more. Some are proprietary applications and some are free but all of them promote using open source tools.

One should leverage this opportunity of open source revolution to enhance its organization’s software functioning. As we all know that there has been a shortage of IBMi developers due to the retirement of old developers and not enough developers wanting to learn the native development of IBMi thus it makes more sense to adopt the OSS ecosystem. To get started with the Open source ecosystem one can easily follow the docs provided by IBM. click here.

PASE uses the Korn shell by default and once can access the shell from within the IBMi 5250 session by running the command CALL QP2TERM and the other way is to do ssh into the system. The method is the preferred one. Also, it would be really handy if we use the Bash shell instead of Korn as Bash has more features and reliability than the Korn shell. Just use yum to get the Bash shell in the system yum install bash. All the open-source package binaries are installed in the path /QOpensys/pkgs/bin.

To instantly reap the benefits of PASE and open source one could start by accessing IFS via SSH although a lot more can be done via the shell this would be the most basic start and easy to adapt. As WRLNK command is used in IBMi to navigate the IFS. The same can be done via SSH access using a terminal on a local workstation(laptop/PC). Below are a few basic steps to do so.

Make sure the SSH demon is running on your IBMi, do NETSTAT *CNN on the command line and check it SSH is in Listen state if not start it by giving the command STRTCPSVR *SSHD.

ssh user@ipaddress
pwd
cd /
ls

After you have the SSH access to the system install a few binaries which are mostly used in OSS development like

yum install bash
yum install gmake
yum install git
yum install python
yum install node16

All the binaries can be found at /QOpensys/pkgs/bin.

For a suitable working environment on the shell check if the user has a directory with his user name in the home directory.

cd ~
cd /home

Both of the above commands take you to the home directory, now do a ls command to list all the unhidden content of the directory, and then do a ls -a to get a list of all the content including hidden fields. There should be a directory with your user name if not then create a new one mkdir UserDir where instead of UserDir you should have your user name. In the user directory create a hidden file touch .profile and then the contents of the file should be PATH=/QOpenSys/pkgs/bin:$PATH
export PATH
TERM=xterm
export TERM
bash Now when you do SSH access again these values will be applied to the terminal, we want to use bash as our default shell because of the many features it provides in an open-source environment.

Now your further steps depend upon what you want to do with your system like doing a web development project using JS and NodeJS/PHP with DB2 integration. Creating APIs to access system data or calling existing programs can be done easily either in Python or NodeJS. Version control using git and GitHub for source hosting if you want otherwise keep your source as stream files.
DevOps using Jenkins or Ansible with other software integration. Ansible is a great tool for system admin work as well. To know more about Ansible read the docs by IBM here.

The below image is a high-level Architectural diagram of IBMi. This image has been taken from Zend’s webpage.

SUBSCRIBE to the newsletter.

Verified by MonsterInsights