0

From a jenkins file I am calling a shell script and passing three environment variables. Below is my shell script

workspace=${2}
build_no=${1}
branch_name=${3}

echo Generatig Javadoc files
"${JDK_HOME}/bin/javadoc" -classpath ${PLANNING_HOME}/lib/Jersey/jersey-core.jar -sourcepath "${PLANNING_HOME}/src" -windowtitle "Oracle Enterprise Performance Management Cloud, Groovy Rules" -header "Oracle Enterprise Performance Management Cloud, Groovy Rules Java API Reference" -bottom "Copyright © 2017, 2020, Oracle and/or its affiliates. All rights reserved." -overview ${workspace}/planning/build/groovy-overview.html -public -nodeprecated -d "/net/slcnas502.us.oracle.com/export/EPM_Planning/PlanningDev/Buzz/tmp_pre_rel/Planning/builds/${branch_name}/${build_no}/javadocgroovy" @${workspace}/planning/build/jdocgroovyfiles_ux.dat

I am consuming jdocgroovyfiles_ux.dat file in shell script. And I want to use env variable workspace in the .dat file but its not working.

${workspace}/planning/HspJS/src/oracle/epm/api/GroovyDynamicLocalizedException.java
${workspace}/planning/HspJS/src/oracle/epm/api/GroovyMessageBundle.java

How to make use of worspace variable in jdocgroovyfiles_ux.dat

Ian Abbott
  • 15,083
  • 19
  • 33
Paul
  • 317
  • 4
  • 15
  • It seems you forgot to `export` the variables you set. This is why these variables are not accessible from the subdprocess. [That question](https://stackoverflow.com/questions/1158091/defining-a-variable-with-or-without-export) explains meaning of `export`. – Tsyvarev Aug 24 '20 at 11:50

1 Answers1

0

Instead of :

@${workspace}/planning/build/jdocgroovyfiles_ux.dat

try :

@<(workspace="$workspace" envsubst < "${workspace}/planning/build/jdocgroovyfiles_ux.dat")

Assuming you are using bash.

To troubke shoot command line issue, run following command :

workspace=/scratch/pqsharma/jenkins/workspace/Planning_develop
cat <(workspace="$workspace" envsubst < "${workspace}/planning/build/jdocgroovyfiles_ux.dat")
Philippe
  • 20,025
  • 2
  • 23
  • 32
  • I am getting below error ``` javadoc: error - cannot read <(workspace=/scratch/pqsharma/jenkins/workspace/Planning_develop envsubst < /scratch/pqsharma/jenkins/workspace/Planning_develop/planning/build/jdocgroovyfiles_ux.dat) (No such file or directory)``` – Paul Aug 25 '20 at 06:44
  • You should not put quotes `"..."` around `@<(...)` – Philippe Aug 25 '20 at 09:15
  • this is how I am using it. Kindly correct me if anything wrong in it --- @<(workspace="$workspace" envsubst < "${workspace}/planning/build/jdocgroovyfiles_ux.dat") – Paul Aug 25 '20 at 14:30