简体   繁体   English

通过 Jenkins 管道代码中的 shell 脚本运行时找不到 SQL 命令

[英]SQL commands not found when run through shell script in Jenkins pipeline code

I'm trying to run following code in Jenkins pipeline through shell script -我正在尝试通过 shell 脚本在 Jenkins 管道中运行以下代码 -

sh'''
            export ORACLE_HOME=$ORACLE_HOME
            export ORACLE_SID=orcl
            cd $ORACLE_HOME/bin
            echo "Starting oracle database..."
            sqlplus /nolog
            conn sys/password as sysdba
            shutdown abort
            startup
            exit success
            echo "done"
            '''

But this results into an error -但这会导致错误 -

SQL> + conn sys/password as sysdba /home/oracle/jenkins/workspace/Database_Error_Handling@tmp/durable-ca459d3c/script.sh: line 7: conn: command not found

None of the commands are not found however same command works fine from the machine.没有找到任何命令,但是相同的命令在机器上工作正常。 Can you please help to understand what could be wrong here?你能帮忙理解这里可能出了什么问题吗?

Try using below script and replace the script which you want to execute in the sqlplus prompt尝试使用以下脚本并在 sqlplus 提示符下替换要执行的脚本

export ORACLE_HOME=$ORACLE_HOME
export ORACLE_SID=orcl
echo "Starting oracle database..."
$ORACLE_HOME/bin/sqlplus "/nolog"  **<<  EOF**

select name from v$database;

exit;

-- Replace the above 2 lines which you want to execute it in sqlplus

**EOF**

echo "done"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM