Hello,
Great news!
Thanks,
Scott
Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Hello,
Great news!
Thanks,
Scott
Hi Steve,
scriptExists does come back as false. But my main point is that the job is marked as failure regardless. Odd that I see 'INFO: Execution run succeeded' in a job failure. I assume that this message indicates that the process itself did not experience any "internal errors"?
Thanks,
Scott
Hi Steve,
Unfortunately, I still get 'ERROR: The raft Default does not contain an asset of type Script with the name FooBar.ps1.'
Thanks,
Scott
Hello Dean,
Here is a test script:
try
{
Get-Asset FooBar.ps1
(
Overwrite: true,
Type: Script,
To: D:\temp\FooBar.ps1
);
}
catch
{
Log-Information did we catch?;
}
Here is the Otter output:
DEBUG: Beginning execution run...
INFO: Execution run succeeded.
DEBUG: Beginning execution run...
INFO: Execution run succeeded.
DEBUG: Beginning execution run...
INFO: Execution run succeeded.
DEBUG: Beginning execution run...
INFO: Execution run succeeded.
DEBUG: Job will be run against servers sequentially (not asynchronously).
DEBUG: Targeting servers: Otter host <host>
INFO: did we catch?
INFO: did we catch?
ERROR: The raft Default does not contain an asset of type Script with the name FooBar.ps1.
DEBUG: Cleaning up temporary files on Local Server...
Thanks,
Scott
Hello Alana,
I tried that, but the catch returns as error if the file doesn't exist and fails the job.
Thanks,
Scott
Hello Alana,
We want to add to our current functionality and make it backward compatible. We have an archive job running in Jenkins which then uploads a config file to Otter and triggers a job. That Otter job runs remotely using Otter\PowerShell scripts with that config file and an input. What we want to do is have a related archive job with its own config file use the same Otter\PowerShell scripts. The issue is, we cannot guarantee that both config files will exist. It would help greatly if we can conditionally get an asset.
Thanks,
Scott
Hi,
I am trying to conditionally run Get-Asset in an Otter script based on the existence of a script in the default raft. I am using curl and regardless if the script is there or not, I always get a positive return. Example (foo.config does not exist):
curl.exe --head "https://<server_url>/0x44/Otter.WebApplication/Inedo.Otter.WebApplication.Pages.Scripts.ListScriptsPage/DownloadAsset?id=Default::BinaryFile::<path_to_script>/foo.config"
HTTP/1.1 302 Found
How can I either conditionally run Get-Asset or use curl to check for a script in the raft?
Thanks,
Scott
Hi Alana,
This seems to work for what I am trying to accomplish.
Thanks!
Scott
Hi Alana,
What I am trying to do is capture the result (success or fail) of this call:
InedoCore::Exec
(
FileName: pwsh,
WorkingDirectory: C:\,
Arguments: test.ps1,
ErrorOutputLogLevel: Error,
OutputLogLevel: Information,
SuccessExitCode: == 0
);
My understanding is that currently InedoCore::Exec does not have a return value. I was hoping for something like:
$ret = InedoCore::Exec
(
...
);
if $ret == "0"
{
// do operations for success
}
else
{
// do operations for failure
}
Thanks!
Scott
Any updates on this?
Thanks!
Scott
@dean-houston Hi Dean,
I did try setting the return of my PowerShell test script to exit -1 which fails the InedoCore::Exec call as expected. I just need to capture that failure and test on it.
Thanks,
Scott
@dean-houston Hi Dean,
I am having a difficult time understanding the workflow here.
As an experiment, I run a ps1 which sets $Fail to "true" as an Ad Hoc job:
InedoCore::Exec
(
FileName: pwsh,
WorkingDirectory: C:\,
Arguments: test.ps1,
ErrorOutputLogLevel: Error,
OutputLogLevel: Information,
SuccessExitCode: == 0
);
if $Fail == "true"
{
InedoCore::Send-Email
(
...
);
}
I get this: Could not resolve variable $Fail.
Do you have a working example? I must be missing something.
Also, what is the purpose of SuccessExitCode if you cannot test on it?
Thanks!
Scott
Hi Alana,
Are you planning on adding a return value for an Exec operation? In my job, I call an otter script which calls pwsh via Exec and would like to send an email based on its return (success\failure).
Thanks!
Scott
Hi Dean,
Setting RaftItemType_Code = 7 in this instance worked for me. Appreciate the list of valid types. Thanks for all of your help!
Scott
Hi Dean,
Here is what I'm running:
Invoke-WebRequest -Method Post -Uri "https://<otter_server>/api/json/Rafts_CreateOrUpdateRaftItem" -Body @{
API_Key = "<apikey>"
Raft_Id = 1
RaftItemType_Code = 4
RaftItem_Name = "JobConfigs/test.yml"
ModifiedOn_Date = Get-Date
ModifiedBy_User_Name = "scusson"
Content_Bytes = [System.Convert]::ToBase64String([IO.File]::ReadAllBytes("D:\test.yml"))
}
If I add the text file (test.yml) thru the UI, it gets added as binary.
Thanks,
Scott
Hi,
This functionality is fixed in 2024.4. However, the script gets created as type "Unknown". How can this be set and what types are valid?
Thanks,
Scott
Hi Alana,
I updated my instance to 2024.2 and still get the same error.
Thanks,
Scott
Hi,
Thanks for the example. However, I still get the error 'Invalid value for "Content_Bytes": Invalid cast from 'System.String' to 'Inedo.Data.VarBinaryInput'' with this body:
API_Key = "xxxxx"
Raft_Id = 1
RaftItemType_Code = 4
RaftItem_Name = "JobConfigs/test.yml"
ModifiedOn_Date = Get-Date
ModifiedBy_User_Name = "scusson"
Content_Bytes = [System.Convert]::ToBase64String([IO.File]::ReadAllBytes("D:\foo\bar\test.yml"))
It appears that the .yml is being detected as binary?
Scott
Hi,
I'm on 2024.1. In this instance, I use Add Script->Upload Scripts & Assets because I already have the file on disk. I will use the "Create a Blank Script" method as a workaround.
Also, can you provide an example of uploading a file from disk?
Thanks!
Scott