簡體   English   中英

如何在 jenkins 和 Microsoft SQL Server 之間建立連接

[英]How to establish connection between jenkins and Microsoft SQL Server

我想使用 Jenkins Job 或 Pipeline 運行 SQL 查詢。 我不知道如何在它們之間建立連接。

如果在 SQL 文件或存儲過程中進行了任何更改,則只應運行該作業(如 github 自動提交)。

誰能幫我這個?

這不是一個確切的答案(而是一個建議) - 當我用谷歌搜索時,我得到了一個唯一的解決方案,即安裝一個名為 SQLCMD exe 文件的插件。 如果它對您不起作用,請嘗試以下方法(我這邊的解決方法)。

If you use Java - 

* Write a java program to connect to the Database and run select query / any queries.
* Make that java program as a jar file (which includes Oracle/SQL or any other dependency jars)
    * The program in java includes -
        * Connect DB
        * Fetch details (select / any query)
        * Write output to a text file (say output.txt)

* Write a shell script to run the Jar file (with command `java -jar GetDetailsFromDB.jar`)
    * The program in shell script includes -
        * Run java -jar (above) command
        * Read output.txt file 
        * echo/cat output.txt file in JenkinsConsole

從 Jenkisfile 運行 shell 腳本很容易

注意
您可能需要將 jar 文件(java 程序)推送到某個工件或 GitHub,以便從 jenkins 中讀取。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM