Value: <% st2kv( system.$.combinedKey ) %>

yaql

(Peter Michael Gits) #1
    vars:
        value: unspecified
        combinedKey: <% $.scope %>.<% $.key %>
    vars:
        value: unspecified
        combinedKey: <% $.scope %>.<% $.key %>

been running through the publish statement and trying to figure out how I get the variable $.st2_execution_id or env().st2_execution_id into the actual variable to be able to fetch it for the ‘st2kv’. While the below 'system.leastBusyBuildServer' works as expected, doing something like 'system.$.st2_execution_id.exit_status' doesn’t expand the variable and I get back

state_info: "Failed to handle action completion [error=Can not evaluate YAQL expression [expression=st2kv( system.$.combinedKey ), error=No function “#operator_.” matches supplied arguments, data={}], wf=examples.mistral-kv, task=task1, action=std.noop]:

    publish:
# fails               value: <% st2kv( <% $.scope%>.<% $.key %> ) %>
#  fails              value: <% st2kv( '$.combinedKey' ) %>
#  fails              value: <% st2kv( $.combinedKey) %>
#worked                value: <% st2kv( 'system.leastBusyBuildServer' ) %>
#fails                value: <% st2kv('system.$.st2_execution_id.exit_status' )

I have also tried this in the

    vars:
        last_exit_prep_all:  concat("'" , "st2_id" , "." , $.last_exit_prep, "." , "exit_status" , "'")
        st2_execution_id: <% env().st2_execution_id %>

publish:
                 exit_status_string: <% st2kv($.last_exit_prep_all) %>

also fails…


(Lindsay Hill) #2

What’s the actual problem you’re trying to solve here?


(Peter Michael Gits) #3

this worked, struggling for too long… removing the single quotes solved this for me yeah!!

vars:
    value: unspecified
    combinedKey: <% $.scope %>.<% $.key %>
input:
   - key
   - scope
output:
    stdout: <% $.value %>
  
tasks:
    task1:
        action: std.noop
        publish:
            value: <% st2kv( $.combinedKey ) %>