Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepowershell
titleExample how to store changes to a local Git repository
linenumberstrue
Import-Module JS7
Connect-JS7 -Url http://root:root@test-_host:4446 -Id 'Controller' | Out-Null

# Cleanup local repository by removing existing objects
Remove-JS7RepositoryItem -Folder '/Accounting'

# Store scheduling objects of the given folder and exclude draft versions to be used
Set-JS7RepositoryItem -Folder '/Accounting' -Recursive -NoDraft

...

Code Block
languagepowershell
titleExample how to commit and push changes to a remote repository
linenumberstrue
Import-Module JS7
Connect-JS7 -Url http://root:root@test-_host:4446 -Id 'Controller' | Out-Null

# Add, commit and push changes to the remote Git repository
Invoke-JS7GitRepositoryAdd -Folder '/Accounting'
Invoke-JS7GitRepositoryCommit -Folder '/Accounting' -Message 'changes for release v1.13'
Invoke-JS7GitRepositoryPush -Folder '/Accounting'

...

Code Block
languagepowershell
titleExample CI/CD pipeline script for test environment
linenumberstrue
collapsetrue
# --- Parameterization ---

$url = 'http://root:root@test-_host:4446'
$controllerId = 'Controller'
$folder = '/Accounting'


# --- Connection ---

Import-Module JS7
Connect-JS7 -Url $url -Id $controllerId | Out-Null


# --- Step 1: Check status of releasable and deployable objects ---

$items = Get-JS7ReleasableItem -Folder $folder -NoReleased
if ( $items.count )
{
    Write-Warning "CI/CD pipeline stopped: unreleased objects found:"
    foreach( $item in $items )
    {
        Write-Warning "unreleased object: type=$($item.objectType), valid=$($item.valid), folder=$($item.folder), name=$($item.objectName)"
    }

    # optionally release items
    $items | Publish-JS7ReleasableItem
}

$items = Get-JS7DeployableItem -Folder $folder -NoDeployed
if ( $items.count )
{
    Write-Warning "CI/CD pipeline stopped: undeployed objects found:"
    foreach( $item in $items )
    {
        Write-Warning "undeployed object: type=$($item.objectType), valid=$($item.valid), folder=$($item.folder), name=$($item.objectName)"
    }

    # optionally deploy items
    $items | Publish-JS7DeployableItem -ControllerId $controllerId
}


# --- Step 2: Cleanup repository and store scheduling objects to repository ---

# Cleanup local repository by removing existing objects
Remove-JS7RepositoryItem -Folder $folder
 
# Store scheduling objects of the given folder and exclude draft versions to be used
Set-JS7RepositoryItem -Folder $folder -Recursive -NoDraft


# --- Step 3: add objects, commit and push to remote repository ---

Invoke-JS7GitRepositoryAdd -Folder $folder
Invoke-JS7GitRepositoryCommit -Folder $folder -Message 'changes to accounting jobs for v12.3'
Invoke-JS7GitRepositoryPush -Folder $folder


# --- Connection ---

Disconnect-JS7

...

Code Block
languagepowershell
titleExample how to pull changes to a local Git repository
linenumberstrue
Import-Module JS7
Connect-JS7 -Url http://root:root@prod-_host:4446 -Id 'Controller' | Out-Null

# Pull changes from remote Git repository
Invoke-JS7GitRepositoryPull -Folder '/Accounting'

...

Code Block
languagepowershell
titleExample how to store changes to a local Git repository
linenumberstrue
Import-Module JS7
Connect-JS7 -Url http://root:root@prod-_host:4446 -Id 'Controller' | Out-Null

# Update the JOC Cockpit inventory from the local repository of the given folder
Update-JS7FromRepositoryItem -Folder '/Accounting'

# Release scheduling objects of the given folder
Publish-JS7ReleasableItem -Folder '/Accounting' -Recursive -NoReleased

# Deploy scheduling objects from the given folder to the Controller
Publish-JS7DeployableItem -ControllerId 'Controller' -Folder '/Accounting' -Recursive -NoDeployed

...

Code Block
languagepowershell
titleExample CI/CD pipeline script for prod environment
linenumberstrue
collapsetrue
# --- Parameterization ---

$url = 'http://root:root@prod-_host:4446'
$controllerId = 'Controller'
$folder = '/Accounting'

$repo = 'git@github.com:sos-berlin/js7-demo-inventory-rollout-test.git'
$commitHash = '04b07d8'


# --- Connection ---

Import-Module JS7
Connect-JS7 -Url $url -Id $controllerId | Out-Null


# --- Step 1: Cherry-pick changes from remote test repository to remote prod repository ---

# navigate to local repository folder on prod host
cd C:\ProgramData\sos-berlin.com\js7\joc\jetty_base\resources\joc\repositories\rollout\Accounting

# add the test repo as a remote repository
git remote add oldrepo $repo
 
# get the test repo commits
git remote update
 
# examine the whole tree
git log --all --oneline --graph --decorate
 
# copy/cherry-pick the commits from the test repo into your local prod repo
git cherry-pick $commitHash
 
# check local prod repo
git log
 
# push changes to remote prod repo
git push origin master
 
# remove the reference to the test repo
git remote remove oldrepo


# --- Step 2: Pull Changes to local Git Repository ---

# Pull changes
Invoke-JS7GitRepositoryPull -Folder $folder


# --- Step 3: Cleanup repository and store scheduling objects to repository ---

# Update the JOC Cockpit inventory from the local repository of the given folder
Update-JS7FromRepositoryItem -Folder $folder
 
# Release scheduling objects of the given folder
Publish-JS7ReleasableItem -Folder $folder -Recursive -NoReleased
 
# Deploy scheduling objects from the given folder to the Controller
Publish-JS7DeployableItem -ControllerId $controllerId -Folder $folder -Recursive -NoDeployed


# --- Connection ---

Disconnect-JS7

...