E

Issues with SAVE ARTIFACT command

Summary

The text discusses problems with the SAVE ARTIFACT command, which now supports directories via wildcard usage but encounters errors in a TRY/CATCH/FINALLY structure due to its inability to handle wildcard paths. The sender requests Christian to share his Earthfile code and proposes manually implementing logic in bash to manage non-zero exits to avoid failures in the earthly build.

Status
open
Tags
    Source
    #earthly
      c

      c.ruppert

      7/31/2024

      hm, yeah, that could work

      b

      brandon

      7/29/2024

      hmm, I guess the SAVE ARTIFACT is implemented differently in the TRY/FINALLY context :confused: Wonder if you could implement the logic manually, e.g. handling the non-zero exit in bash so that the earthly build doesn’t fail

      c

      c.ruppert

      7/25/2024

      earthly version v0.8.15 cb38f72663696d17d8393b1cc8bac66aed28faa2 linux/amd64; Ubuntu 24.04 LTS (Noble Numbat)

      c

      c.ruppert

      7/25/2024

      > Error: Earthfile:143:8 TRY/CATCH/FINALLY does not (currently) support wildcard SAVE ARTIFACT paths and without wildcard, just the directory, I get that previous mentioned error

      ...
      vtest-haproxy:                                                                                                                                                                                                                                                 
          ARG --required DEB_CODENAME                                                                                                                                                                                                                                
          FROM +debian-build-deps --DEB_CODENAME=${DEB_CODENAME}                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                     
          ARG --required HAPROXY_VER                                                                                                                                                                                                                                 
          WORKDIR /src                                                                                                                                                                                                                                               
          COPY (+haproxy-src/src --HAPROXY_VER=${HAPROXY_VER}) ./                                                                                                                                                                                                    
          COPY --dir (+binary/out --HAPROXY_VER=${HAPROXY_VER} --DEB_CODENAME=${DEB_CODENAME}) /                                                                                                                                                                     
          COPY (+vtest/vtest --DEB_CODENAME=${DEB_CODENAME}) /vtest                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                     
          TRY                                                                                                                                                                                                                                                        
              RUN HAPROXY_PROGRAM=/out/usr/sbin/haproxy VTEST_PROGRAM=/vtest make -j$(nproc) reg-tests                                                                                                                                                               
          FINALLY                                                                                                                                                                                                                                                    
              SAVE ARTIFACT /tmp/ AS LOCAL .                                                                                                                                                                                                                         
          END ```
      
      b

      brandon

      7/24/2024

      Can you share some of your Earthfile code?

      b

      brandon

      7/24/2024

      Hi Christian, I believe SAVE ARTIFACT with directories should work. And wildcard support was added recently.

      c

      c.ruppert

      7/22/2024

      <@U02NXMDQ45Q> is there any workaround by chance? the names are really random so I'd need that entire directory or wildcard :confused:

      c

      c.ruppert

      7/5/2024

      ah, ok, wildcard isn't supported yet and directory doesn't seem to work either :thinking_face: > +vtest-haproxy failed | earthly debugger | failed to save /tmp/: read /tmp/: is a directory

      c

      c.ruppert

      7/3/2024

      ah, thanks!

      b

      brandon

      7/3/2024

      This might be what you’re looking for https://docs.earthly.dev/docs/earthfile#try-experimental

      c

      c.ruppert

      7/3/2024

      hey, is it possible to save artifacts for a failed command?