将Env变量从Shell脚本传递到.dat文件

时间:2020-08-24 09:32:01

标签: linux shell sh

从jenkins文件中,我正在调用Shell脚本并传递三个环境变量。下面是我的shell脚本

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

我正在使用Shell脚本中的jdocgroovyfiles_ux.dat文件。而且我想在.dat文件中使用env变量工作区,但无法正常工作。

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

如何在jdocgroovyfiles_ux.dat中使用worspace变量

1 个答案:

答案 0 :(得分:0)

代替:

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

尝试:

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

假设您正在使用bash。

要解决射击命令行问题,请运行以下命令:

workspace=/scratch/pqsharma/jenkins/workspace/Planning_develop
cat <(workspace="$workspace" envsubst < "${workspace}/planning/build/jdocgroovyfiles_ux.dat")