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!

Help with Git raft in Otter



  • Hi All,

    I am using Otter 3.0 and trying to setup a Git raft, that uses GitHub.

    I configured a secure credential that uses my username and a PAT token (Type is username/password).

    I then configured a GitHub raft, with the branch being main, and a username and same PAT token.

    However, when I browse the raft, there's no errors, but I don't see my files that I have commited to the branch?


  • inedo-engineer

    Hi @gurdip-sira_1271,

    How were the files added to your Git repository? Were they initially added from Otter? When you navigate to Administration -> Raft Repositories and you click "browse" to the right of your Git raft, do you see any files that show there?

    Thanks,
    Dan



  • They were addef by git commit, outside of Otter. Using vs code. I see the view in the attached screenshot.

    git-otter.PNG

    Is there a trick I am missing somewhere?



  • Ok so if I have a blank repo and the same config in secure credentials, I can add a script to Otter and in the raft and it appears.

    My only issue with this iswhat should my workflow be? I was hoping to retain the standard git workflow ie commit push etc.


  • inedo-engineer

    Hi @gurdip-sira_1271 ,

    Great, sounds like its working :)

    I think the issue is that you didn't have the folder-structure in place. Scripts should go in the /scripts folder basically.

    Cheers,
    Alana



  • @atripp said in Help with Git raft in Otter:

    e its working :)
    I think the issue is that you did

    Would that folder be in Inedo Otter or in Git, or both?


  • inedo-engineer

    Hi @gurdip-sira_1271 ,

    Your Git repository must be structured in a particular way to work as a Git Raft; but it's best to let Otter manage all of that. Here is a sample: https://github.com/Inedo/OtterRaftTest

    The repository you use for a Git-based raft shouldn't be used for anything else - just raft storage.

    Cheers,
    Alan



  • Ok am I safe to import that test repo into my repo?

    Sorry for all the questions, just this part of Otter seems to lack detail in steps!


  • inedo-engineer

    Hi @gurdip-sira_1271,

    I think the safer option would be to upload your scripts on the "Scripts" page in Otter. If you navigate to the "Scripts" page, click "Add Script", and then select "Upload Scripts & Assets". You can then select your Git raft and then bulk upload all your script files. This way, they all get put in the correct folder automatically.

    Thanks,
    Rich



  • Is that how this feature works though? Could I not just do a git commit to the repo and then use the scripts in Otter?

    I seem to have this working, not quite sure what is the exact config needed (hence the request to just provide the steps end-to-end. I like the product but the documentation is lacking slightly here).

    So now, when I add a file to my git repo, it shows in the Scripts area, which is all I need. :)


  • inedo-engineer

    @gurdip-sira_1271 said in Help with Git raft in Otter:

    Could I not just do a git commit to the repo and then use the scripts in Otter?

    Hi @gurdip-sira_1271,

    Yes, you can commit your scripts directly to Git by adding them to the Scripts folder. You can also modify your scripts directly in your Git repository as well or you can use the editor directly in Otter. We also just added a new text editor based on Monaco (the same editor as VS Code) and a new visual editor for OtterScript available as a preview feature in the latest version of Otter (3.0.24).

    We don't have direct end-to-end steps on adding scripts directly in Git because that has not been the most typical way users have used this feature. Typically, a user adds the script via Otter and then will edit them in git.

    The other way git rafts are used is with git branches. A raft is created for each git branch where the editing and testing of scripts are done in one branch and the production scripts are stored in another branch. This can become tricky though when calling scripts for different rafts in OtterScripts.

    Hope this helps!

    Thanks,
    Rich



  • Hmm I get your point about branching.

    Is there a way in the Raft to sany branch BUT main? As pr branches could be called anything.


  • inedo-engineer

    Hi @gurdip-sira_1271 ,

    I want to share this guidebook that we wrote;
    https://inedo.com/support/resources/ebooks/windows-first-iac-cca

    Basically it discusses and walks you through how to CI/CD with your "infrastructure as code" using Otter and BuildMaster (our CI/CD tool). The screenshots are outdated, but after a lot of research, our conclusion is that the "pipeline" approach is likely the best.

    Cheers,
    Alana



  • I will give that a read.

    Two questions;

    1. How does Otter handle jobs that may require reboots in betwen/ For example, joining a domain.

    2. I have added some text files to my git repo but Ot

    One last question - in my git raft, I have a script that looks like this:

    $chocoPackages = $PSScriptRoot + "\chocoPackages.txt"
    
    $DB = Get-Content $chocoPackages
    
    foreach ($Data in $DB) {
    choco install $DB -y
    }
    

    However, I get the error:

    Cannot find path 'C:\chocoPackages.txt' because it does not exist.

    What am I missing?
    Oneter reports them as unknown file type.


  • inedo-engineer

    Hi @gurdip-sira_1271

    There is a Restart-Server OtterScript operation that you can use. You can specify a timeout/timer.

    You'll want to store that chocoPackages.txt file as a script asset, and then deploy it to the server you're running the scripts on:

    Get-Asset chocoPackages.txt
    (
        Type: File
    );
    

    However, you may want to consider this approach for your chocopackges:

    https://docs.inedo.com/docs/otter-howto-ensure-chocolatey-packages



  • I guess the bit I am confused about is if a restart is needed mid script. Would the agent on the server resume the script post reboot?

    For script assets, how would I reference from my Powershell script? Or should I use OtterScript and then have the step above and then my script?



  • To add, I get this error when making a job template:

    "KillerGamingWindowsPowershell::JobTemplate::KillerGamingWindowsPowershell::Jobs/t" is not a valid raft item identifier.

    Sorry for all the questions, just trying to get myelf up and running!



  • In addition, when I drag a ps1 script in an otterscript orchestration, the popup is blank and i can't add the script. eg:

    blank.PNG


  • inedo-engineer

    Hi @gurdip-sira_1271,

    I guess the bit I am confused about is if a restart is needed mid script. Would the agent on the server resume the script post reboot?

    You would need to perform the restart in OtterScript.

    for server REMOTEMACHINE
    {
       PSCall MyScript1.ps1;
    
       Restart-Server;
    
       PSCall MyScript2.ps1;
    }
    

    For script assets, how would I reference from my Powershell script? Or should I use OtterScript and then have the step above and then my script?

    In this case, you'll want to use OTterScript to deploy the script assets first.

    To add, I get this error when making a job template:

    That's a regression, and we'll fix it pretty soon. It has to do with Job Template folders in Git Rafts. We're shipping Otter v2022 today actually :)

    In addition, when I drag a ps1 script in an otterscript orchestration, the popup is blank and i can't add the script.

    Does your script have any parameters? If so, that is to be expected. Its should save if you hit the save button however. Note that in Otter v2022, shipping very soon, the script editor is totally rewritten and should be fixed.

    Cheers,
    Alana



  • Ok thanks, I will try otter v2022.

    The bit I am not sure about is what my ps1 code should look like for the file reference to the text file.

    The script has no parameters. The behaviour seems a bit erratic. Are you referring to v3.0.24? As I tried this and no change.


  • inedo-engineer

    Hi @gurdip-sira_1271 ,

    If your script has no parameters, then there's nothing to really show on the Visual Editor. However, you should be able to save the statement.

    Behind the scenes, the visual editor should just make a PSCall Set-WebServer; in text mode. What does the text mode look like?

    Cheers,
    Alana



  • Hmm, nothing in text mode, but I have to cancel and then view.

    The other confusing thing is with multiple git-based rafts, it's not clear which script is part of which raft.


  • inedo-engineer

    @gurdip-sira_1271 it's possible there's a bug in the visual mode with that, especially w/ rafts...

    Here is how you you would call scripts from another raft:
    PSCall RaftName::Set-WebServer;

    When you don't specify a raft name, then Default is used as the raft.



  • @atripp said in Help with Git raft in Otter:

    PSCall RaftName::Set-WebServer;

    ok let me try that.



  • OK i get an error stating the script cannot be found. I think that's because in the visual plan, the sript doesn't appear anyway.


  • inedo-engineer

    Hi @gurdip-sira_1271,

    Just to let you know, Otter v2022 has been released; from here it'd be best to start a new thread if you have a specific issue -- we'll be happy to help!

    Steve


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation