Versions Compared

Key

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

...

The below example includes use of the above cmdlets in a pipeline script.

Download PowerShell ScriptRollout-JS7FromTest.ps1

...

The below example includes use of the above cmdlets in a pipeline script.

Download PowerShell ScriptRollout-JS7ToProd.ps1

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

$url = 'http://root:root@localhost:4446'
$controllerId = 'Controller'

$folder = '/TestRepo/testMyFolder'
$directory = 'C:\ProgramData\sos-berlin.com\js7\joc\jetty_base\resources\joc\repositories\rollout\TestRepo'

$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 test repository to prod repository ---

cd $directory

# 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 ---

cd $directory

# Pull changes
git pull


# --- 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

...