Page History
Table of Contents |
---|
Introduction
JS7 offers JS7 - Inventory Git Integration for JS7 - Rollout of Scheduling Objects.
- Git access includes
...
- authentication with
...
- a Git
...
- Server and
...
- accessing remote repositories.
- The
...
- setup of a local repository is explained with the JS7 - How to set up a local Git Repository article.
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
A 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 can may look like this:
Code Block | ||||
---|---|---|---|---|
| ||||
Host github.com Hostname github.com IdentityFile C:\Users\me\.ssh\github_rsa IdentitiesOnly yes |
Explanation:
- The settings map the use of a specific private key identity file to authentication with a specific Git serverServer.
Git Configuration Items
Typical configuration A typical configuration step performed with a Git client looks like this:
Code Block | ||||
---|---|---|---|---|
| ||||
# Specify user name git config --global user.name "ItsMy MeAccount" # Specify e-mail addresseaddress git config --global user.email "its.me@examplemyAccount@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:
- The JS7 - REST Web Service API allows the same operations to be performed for Git integration as are provided in the JOC Cockpit GUI.
- 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.
- Execution of the PowerShell examples with the
The documentation for related cmdlets can be found in PowerShell CLI 2.0 - Cmdlets - Git Repository Integration.
Display feature availability | ||
---|---|---|
|
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# 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:
- Line 2-6: Variables which are used by the subsequent examples.
- Line 9-10: The JS7 PowerShell Module is loaded and the connection to the JOC Cockpit established - see JS7 - How to connect to JOC Cockpit using the PowerShell Module.
- Line 13: The Add-JS7GitCredentials cmdlet allows Git credentials to be stored with the user account's profile. A private key file is specified. This file has to exist and is expected in the locations indicated with JS7 - Inventory Git Integration, chapter: Manage Credentials for Git Access.
- Line 16, 19: Alternative authentication methods for Git access.
- Line 22: The Remove-JS7GitCredentials cmdlet deletes Git credentials from the user account's profile.
- Line 25: The connection to JOC Cockpit is closed.