Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    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!

    Using curl to either check or download a script file in Otter

    Scheduled Pinned Locked Moved Support
    13 Posts 4 Posters 67 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • atrippA Offline
      atripp inedo-engineer
      last edited by

      Hi @scusson_9923 ,

      One idea ... how about a try/catch block?

      It's not great.... but the catch will indicate the file doesn't exist.

      Just a thought...

      Thanks,
      Alana

      1 Reply Last reply Reply Quote 0
      • S Offline
        scusson_9923
        last edited by

        Hello Alana,

        I tried that, but the catch returns as error if the file doesn't exist and fails the job.

        Thanks,
        Scott

        dean-houstonD 1 Reply Last reply Reply Quote 0
        • dean-houstonD Offline
          dean-houston inedo-engineer @scusson_9923
          last edited by

          Hi @scusson_9923 ,

          Can you share the OtterScript where you tried the try/catch ? Perhasp that's just something we can more easily fix.

          -- Dean

          1 Reply Last reply Reply Quote 0
          • S Offline
            scusson_9923
            last edited by stevedennis

            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

            stevedennisS 1 Reply Last reply Reply Quote 0
            • stevedennisS Offline
              stevedennis inedo-engineer @scusson_9923
              last edited by

              Hi @scusson_9923 ,

              Sorry on the slow reply; i wanted to test this, but didn't get a chance and figure I'd just share this now (which should work):

              set $scriptExists = true;
              
              try
              {
                  Get-Asset FooBar.ps1
                  (
                      Overwrite: true,
                      Type: Script,
                      To: D:\temp\FooBar.ps1
                  );
              }
              catch
              {
                  set $scriptExists = false;
                  force normal;
              }
              
              Log-Information scriptExists: $scriptExists;
              

              Cheers,
              Steve

              1 Reply Last reply Reply Quote 0
              • S Offline
                scusson_9923
                last edited by

                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

                stevedennisS 1 Reply Last reply Reply Quote 0
                • stevedennisS Offline
                  stevedennis inedo-engineer @scusson_9923
                  last edited by

                  Hi @scusson_9923 ,

                  The message is expected, but you should see scriptExists: false written at the end, and aNormal status (i.e. green) for the execution.

                  Is that not the case?

                  Thanks,
                  Steve

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    scusson_9923
                    last edited by stevedennis

                    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

                    stevedennisS 1 Reply Last reply Reply Quote 0
                    • stevedennisS Offline
                      stevedennis inedo-engineer @scusson_9923
                      last edited by

                      Hi @scusson_9923 ,

                      Looks like this is a bug in not overriding the job/execution status; the force normal statement should make it "green" and a normal execution status. Anyway we'll get it fixed via OT-524.

                      Cheers,
                      Steve

                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        scusson_9923
                        last edited by

                        Hello,

                        Great news!

                        Thanks,
                        Scott

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          Last post
                        Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation