Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Create a global variable in Oozie to be accessible to all actions?

Solved Go to solution

Create a global variable in Oozie to be accessible to all actions?

New Contributor

I want to create a variable that should be available to all the actions in the Oozie workflow. I have tried to create it as shown below. But EL expression is not getting evaluated resulting in variable current_ts value as EL expression itself. Can somebody please throw some light on this?

    <workflow-app xmlns="uri:oozie:workflow:0.4" name="no-op-wf">
      <parameters>
        <property>
          <name>current_ts</name>
          <value>${replaceAll((replaceAll((replaceAll((timestamp()),"-","")),"T","_")),":","")}</value>
        </property>
      </parameters>
      <start to="test"/>
      <kill name="test">
        <!--message Just to show that this expression works if used here>Timestamp - [${replaceAll((replaceAll((replaceAll((timestamp()),"-","")),"T","_")),":","")}</message-->
        <message>Timestamp - ${current_ts}</message> <!-- this will print expression but not evaluate it -->
      </kill>
      <end name="end"/>
    </workflow-app>

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Create a global variable in Oozie to be accessible to all actions?

Expert Contributor

@Abb Code Just try to see if by defining the required variable through global section in workflow.xml helps you. More details about defining global is available at following URL.

https://oozie.apache.org/docs/4.2.0/WorkflowFunctionalSpec.html#a19_Global_Configurations

2 REPLIES 2

Re: Create a global variable in Oozie to be accessible to all actions?

Expert Contributor

@Abb Code Just try to see if by defining the required variable through global section in workflow.xml helps you. More details about defining global is available at following URL.

https://oozie.apache.org/docs/4.2.0/WorkflowFunctionalSpec.html#a19_Global_Configurations

Re: Create a global variable in Oozie to be accessible to all actions?

New Contributor

Thanks @peeyush . I was able to use global property section to create a global variable and reference it in different actions in workflow. But it didn't work in the same workflow, I had to pass it to a sub workflow as a configuration property from another workflow.

  <global>
    <configuration>
      <property>
        <name>run_ts</name>
        <value>${replaceAll((replaceAll((replaceAll((timestamp()),"-","")),"T","_")),":","")}</value>
      </property>
    </configuration>
  </global>


 <action name="coaching-tbl-subwf">
    <sub-workflow>
      <app-path>/data/app/subwf.xml</app-path>
      <propagate-configuration/>
 </configuration>
    </sub-workflow>
    <ok to="join-node"/>
    <error to="fail"/>
  </action>




Don't have an account?
Coming from Hortonworks? Activate your account here