Versions Compared

Key

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

...

The first job get-history-task-logs looks like this:

Code Block
languagepowershell
titleExample for job get-history-task-logs
linenumberstrue
#!/usr/bin/env pwsh

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

$lastHistory = Get-JS7TaskHistory -RelativeDateFrom -30m | Sort-Object -Property startTime

    # serialize and base64 encode the object
	$xmlLastHistory = [management.automation.psserializer]::Serialize( $lastHistory )
	$lastHistoryEncoded = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes( $xmlLastHistory ))

    # forward a variable for the object
    "lastHistoryEncoded=$lastHistoryEncoded" | Out-File $env:JS7_RETURN_VALUES -Append

Disconnect-JS7

...

The second job write-task-logs-to-files looks like this:

Code Block
languagepowershell
titleExample for job write-task-logs-to-files
linenumberstrue
#!/usr/bin/env pwsh

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

    # bas64 decode and deserialize the object
    $xmlLastHistory = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String( $env:LAST_HISTORY_ENCODED ))
	$lastHistory = [System.Management.Automation.PSSerializer]::Deserialize( $xmlLastHistory )

Get-JS7TaskHistory -DateFrom $lastHistory[0].startTime | Tee-Object -Variable lastHistory | Get-JS7TaskLog | Select-Object @{name='path'; expression={ "/tmp/history/$(Get-Date $_.startTime -f 'yyyyMMdd-hhmmss')-$([io.path]::GetFileNameWithoutExtension($_.job)).task.log"}}, @{name='value'; expression={ $_.log }} | Set-Content

    # serialize and base64 encode the object
	$xmlLastHistory = [management.automation.psserializer]::Serialize( $lastHistory )
	$lastHistoryEncoded = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes( $xmlLastHistory ))

    # forward a variable for the object
    "lastHistoryEncoded=$lastHistoryEncoded" | Out-File $env:JS7_RETURN_VALUES -Append

Disconnect-JS7

...