Versions Compared

Key

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

...

Code Block
languagepowershell
titleExample how to commit and push changes to a remote repository
linenumberstrue
# Find the repository sub-directory managed by JOC Cockpit
cd /var/sos-berlin.com/js7/joc/jetty_base/resources/joc/repositories/rollout/Accounting

# Commit and push changes to the remote Git repository
git add .
git commit -m "changes to accounting jobs for v12.3"
git push

Example for a CI/CD Pipeline Script for TEST Environment

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

Download: Rollout-JS7FromTest.ps1

Code Block
languagepowershell
titleExample CI/CD pipeline script for test 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'


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

cd $directory

git add .
git commit -m "changes to accounting jobs for v12.3"
git push


# --- Connection ---

Disconnect-JS7

...

  • Line 5: The JOC Cockpit inventory is updated from the local repository. This translates to the fact that objects with the same name are overwritten and that new objects are added. Updated objects are put to a draft status in the JOC Cockpit inventory. Find details from Update-JS7FromRepositoryItem.
  • Line 8: Scheduling objects that are not deployed to a Controller such as schedules and calendars are released. Should such objects be included in the changes to the local repository then they are in a draft status and should be released. The -NoReleased parameter prevents scheduling objects in a non-draft status from being released, for example objects that are not stored in the local repository but that have previously been released. For details see Publish-JS7ReleasableItem.
  • Line 11: Scheduling objects are deployed to the given Controller. The -NoDeployed parameter prevents scheduling objects in a non-draft status from being deployed, for example objects that are not stored in the local repository but that have previously been deployed. For details see Publish-JS7DeployableItem.

Example of a CI/CD Pipeline Script for PROD Environment

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

Download: 

Code Block
languagepowershell
titleExample for a
x

Further Resources

The above OS commands, Git commands and PowerShell cmdlets can be executed from JS7 workflows for automation of a CI/CD pipeline.

...