GitHub your approach IBM i

GitHub for IBM i Your Path to Modern Development

Look no further if you have been wondering how to breathe new life into your IBM i development projects.

GitHub, with its robust features and user-friendly interface, is here to revolutionize the way you work with this legacy platform.

Introduction

The GitHub platform revolutionized the way developers collaborate, manage, and track changes in their code. It is widely associated with open-source projects and modern software development, but it is also useful for working with IBM i (formerly known as AS/400 or iSeries). This blog post discusses how GitHub can enhance IBM i development workflows, promote collaboration, and streamline software development.

Why GitHub for IBM i?

IBM i is a robust and secure platform used by businesses for mission-critical applications. However, its reputation for being complex and proprietary has sometimes hindered collaboration and modern development practices. GitHub can bridge this gap and offer numerous benefits to IBM i developers and teams.

The Power of GitHub on IBM i:

1. Version Control:

GitHub provides robust version control through Git. It allows developers on IBM i to track changes to their code, collaborate with others, and easily manage projects. This is essential for ensuring code integrity and rolling back changes if issues arise.

2. Collaboration:

GitHub’s collaborative features, such as pull requests and code reviews enable teams working on IBM i to collaborate effectively to discuss code changes. This fosters teamwork and ensures code quality.

3. Security:

GitHub provides security features like dependency tracking to help IBM i developers identify and address potential security risks in their projects.

4. Community and open source:

IBM i is an excellent platform for developing open-source software. You can share your projects with a broader audience through GitHub, gain contributors, and benefit from open collaboration.

5. Continuous Integration/Continuous Deployment (CI/CD):

Automating development, testing, and deployment processes with GitHub Actions is possible. The use of CI/CD pipelines tailored for IBM i can speed up development cycles, prevent errors, and ensure consistent deployments.

 Pre-Requisite

It is necessary to have Git, GitBash, and an account on GitHub, although it is also possible to use other open sources such as GitLab.

 GitHub on IBM i

Following are the general steps for using GitHub with IBM i (formerly AS/400 or iSeries): -

1. Set up your IBM i environment:

Make sure you have access to an IBM i system.

2. Install Git on IBM i:

Use GitHub, you will need Git installed on your IBM i system. Installing it can be done using a package manager like ACS (Access Client Solutions).

Follow the below steps:

a. Open access client solutions, click “Tools option” and then “open-source package management”.

ibmi-acs

b. The login window will appear below, where you must enter your credentials.

c. Then you will see the next window with packages. Simply click on "available packages" search for "git" and click "install".

OSPM

d. Use your IBM i credentials to log in to your system.

e. Run the “CALL QP2TERM” command.

f. Add path permanently to user profile Run:

echo 'PATH=/QOpenSys/pkgs/bin: $PATH' >> $HOME/. profile && echo 'export PATH' >> $HOME/. profile

There should be a directory in /home/ same as your user’s name e.g., home/USERNAME. If it is not already there, you can create one by doing the following:

  • mkdir /home/USERNAME && touch USERNAME/. profile then do
  • echo 'PATH=/QOpenSys/pkgs/bin: $PATH' >> $HOME/. profile && echo 'export PATH' >> $HOME/. profile

g. Before performing the next commands, restart your session and run “CALL QP2TERM” again

h. On the Qshell interface of IBM I, you can enter the “git-version” command to confirm if the install was successful and to see which version is installed.

3. Generate SSH key:

For GitHub authentication, generate an SSH key pair on your IBM i system if you have not already done so.

For more information, click here: SSH Key Setup and Generating new SSH Key.

Here are the steps you need to follow:

a. Run ssh-keygen -t rsa -b 2048 -C “email@example.com”. Then, to ask for the phrase, you must enter – g.: Shubhangi2023.

b. Run: cat /home/user/.ssh/id_rsa.pub

c. Copy the key from "/home/user/.ssh/id_rsa.pub”.

d. Go to your GitHub account -> settings -> account settings-> SSH & GPG keys, paste the key, and click on the add SSH key button.

add ssh

e. You will receive a message once the key is successfully added!

f. Start the SSH agent by running: eval "$(ssh-agent -s)", which gives you the agent ID.

g. After that, run ssh-add ~/.ssh/id_rsa to add the SSH key to the SSH agent.

h. Add GitHub to your known host, run [SL1] ssh-keyscan github.com >> ~/.ssh/known_hosts.

4. Clone GitHub Repository:

a. You can use your existing repository on GitHub or create a new one.

For more information, click here: How to create a repository

b. Then, run Git clone <PATH>, which creates a Git directory in your File system. You can find the path on GitHub by searching for your repository, selecting the Code option, and copying the HTTPS path.

gitHub-Qshell

5. Push Changes:

a. After that, from AS400, run the following command to copy object data to the file system directory.

CPYTOSTMF FROMMBR ('/QSYS.LIB/your lib.LIB/your file. FILE/your member.mbr’) TOSTMF (<Directory Path>)     

STMFOPT(*REPLACE)                                  

DBFCCSID(*FILE)                                           

STMFCCSID (1252)                                          

ENDLINFMT(*LF)                                           

AUT(*DFT)

b. From the Qshell interface run - "git add.", which adds all your file staged areas.

c. Then run - "git commit -m "Relevant Message", which saves your file.

i. If you are facing the issue below, see step

d. to resolve.

d. Configure Git: Set your git username and email globally on your local machine using the following commands:

git config --global user.name “Your Name”

git config --global user. Email “Your email”

e. Use the last run - "git push" command, which pushes your file and moves it into the GitHub repo.

i. If you are working from an AS400 system, it might be not able to push as per the below image. See step

f. to resolve.

git-push

f. You can use command prompts such as GitBash and putty to resolve this issue. Using GitBash, simply log in with IBM i credentials using the command “ssh username@IP_address also enter password” and reach your destination directory by performing the below commands.

  • ls: used to check whether the file is there or not
  • git - -version: to check the installed version of Git
  • git init: to create a new empty git repository
  • ls -la: return list of all files including hidden files
  • cd <directory name>: to reach destination directory

git-username-pwd

g. Run git push to push local repository content to a remote repository.

h. The changes you made to your file are visible on GitHub!

i. Click on edit for pull changes and make some changes in the file. The example below shows changing its value from 10 to 20.

j. Click on the commit option to save your changes.

6. Pull changes:

a. Pull changes, run - "git pull" from Git Bash.

run-git-push

b. If you are working from an AS400 system, run the following command to copy the file data into the IBM i object:

CPYFRMSTMF FROMSTMF (<Directory Path>) TOMBR ('/QSYS.LIB/your lib.LIB/yourfile.FILE/member name.MBR’)                         

MBROPT(*REPLACE)                  

ENDLINFMT(*LF)          

c. Open your file. You will see recent changes (i.e., b’s value changed from 10 to 20!).

ibm-see-recent-changes

Conclusion:

GitHub is a valuable addition to the toolkit of IBM i developers and teams. It promotes collaboration, streamlines development workflows, and enhances security practices. By embracing modern development practices with GitHub, IBM i developers can ensure their applications remain competitive, secure, and maintainable in the ever-evolving technology landscape. So, whether you are developing new applications or modernizing existing ones, consider integrating GitHub into your IBM i development process for a more efficient and collaborative experience.

SHARE: