Introduction

JS7 offers JS7 - Inventory Git Integration for JS7 - Rollout of Scheduling Objects.

The steps for setting up access to a Git Server can be applied manually and can also be applied by using the JS7 REST Web Service API.

Manual Setup

Git Configuration File

JOC Cockpit uses a Git client which reads configuration items from the following file (assuming a user account me is in place)

  • for Unix environments:
    • /home/me/.ssh/config
  • for Windows environments:
    • C:\Users\me\.ssh\config

The Git config file may look like this:

Example for Git config file
Host github.com
    Hostname github.com
    IdentityFile C:\Users\me\.ssh\github_rsa
    IdentitiesOnly yes

Explanation:

  • The settings map the use of a private key file to authentication with a Git Server.

Git Configuration Items

A typical configuration step performed with a Git client looks like this:

Example for Git config file
# Specify user name
git config --global user.name "My Account"

# Specify e-mail address
git config --global user.email "myAccount@example.com"

# Use simple merge strategy
git config --global push.default simple

Automation with the JS7 REST Web Service API

Users who wish to automate the steps for setting up Git access can use the following resources:

Automation using the Unix Shell CLI

The JS7 - Unix Shell CLI for Git Deployment offers simplified access to the REST Web Service API for scripting purposes.

FEATURE AVAILABILITY STARTING FROM RELEASE 2.7.1

Example for Managing Git Credentials using Unix Shell
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# get credentials
./deploy-git.sh get-credentials    "${request_options[@]}"

# store credentials
./deploy-git.sh store-credentials  "${request_options[@]}" --server=github.com --user-account=myAccount \
                                   --user-name="My Account" --user-mail="myAccount@example.com" \
                                   --user-private-key=/var/sos-berlin.com/js7/joc/resources/joc/repositories/private/myAccount.rsa

# delete credentials
./deploy-git.sh delete-credentials "${request_options[@]}" --server=github.com

Automation using the JS7 PowerShell Module

The JS7 - PowerShell Module offers simplified access to the REST Web Service API for scripting purposes.

Execution of the PowerShell examples with the -debug option might prove to be instructive for logging REST API calls.

The documentation for related cmdlets can be found in PowerShell CLI 2.0 - Cmdlets - Git Repository Integration.

FEATURE AVAILABILITY STARTING FROM RELEASE 2.3.0

Example for Managing Git Credentials using PowerShell
# Parameterization
$gitServer   = 'github.com'
$gitAccount  = 'myAccount'
$gitUserName = 'My Account'
$gitUserMail = 'myAccount@example.com'
$gitKeyFile  = 'myKey.rsa'

# Connection
Import-Module JS7
Connect-JS7 -Url http://root:root@localhost:4446 -Id 'Controller' | Out-Null

# Use of private key file
Add-JS7GitCredentials -Server $gitServer -Account $gitAccount -KeyFile $gitKeyFile -UserName $gitUserName -UserMail $gitUserMail

# Use of access token (similarly insecure as use of passwords)
# Add-JS7GitCredentials -Server $gitServer -Account $gitAccount -AccessToken 'a1b2c3d4e5f6g7h8' -UserName $gitUserName -UserMail $gitUserMail

# Use of password (denied by a larger number of Git Servers)
# Add-JS7GitCredentials -Server $gitServer -Account $gitAccount -Password (ConvertTo-SecureString 'secret' -AsPlainText -Force) -UserName $gitUserName -UserMail $gitUserMail

# Remove Git credentials
Remove-JS7GitCredentials -Server $gitServer

# Connection
Disconnect-JS7


Explanation: