有沒有辦法在TeamCity中添加構建步驟,該步驟向Jenkins服務器發送請求,在Jenkins中運行一些自動化測試腳本並向Teamcity發回響應。從TeamCity發送命令在Jenkins上運行自動化測試
這個想法基本上是自動化整個部署過程,其中還包括使用python腳本(這將在Jenkins上完成)創建的一些自動化測試的運行。
我不確定這是否是最好的方法,但有沒有更好的方法來實現這一目標?還有關於如何從Teamcity向Jenkins發送命令的提示?
有沒有辦法在TeamCity中添加構建步驟,該步驟向Jenkins服務器發送請求,在Jenkins中運行一些自動化測試腳本並向Teamcity發回響應。從TeamCity發送命令在Jenkins上運行自動化測試
這個想法基本上是自動化整個部署過程,其中還包括使用python腳本(這將在Jenkins上完成)創建的一些自動化測試的運行。
我不確定這是否是最好的方法,但有沒有更好的方法來實現這一目標?還有關於如何從Teamcity向Jenkins發送命令的提示?
您可以發起一個http請求,正如在評論中提到的那樣,可以在Jenkins上開始測試。
至於公佈結果巴赫TeamCity的,可能的解決辦法是:
爲第一部分提供了一個易於實施的解決方案,即從TeamCity發送命令到詹金斯
使用curl:
安裝/複製捲曲到TeamCity的代理。 ,然後在TC生成配置,創建類似下面的一個新的命令行構建的步驟(修改參數,以您的需求)
捲曲--user%jenkins_user%:jenkins_pwd%-X POST http://%jenkins_instance_withport%/job/%jenkins_jobs_name%/buildWithParameters?token=%jenkins_token% --data「 Build_Number =%build.number%「
eg:curl --user admin:password -X POST http://jenkinssever:2123/job/test-build-image/buildWithParameters?token=rtbuild --data」Build_Number = 1.2。0"
這裏我甚至可以使用通過版本號詹金斯‘ - 數據’
執行以下下詹金斯建築結構:
在Jenkins配置中,更新以下值:
「此項目已參數化」
Name: Build_Number
Default Value: 1.2.0
「觸發遠程建立」
Authentication Token: rtbuild
可選:設置集結號
「設置編譯名稱」
Build Name: #${Build_numuber}
做,你是好go.please做讓我知道你是否有更多問題。
上面是最初的註釋實施
I think I found a way while trying to solve similar use-case, did it for batch files in Teamcity build steps. for Jenkins, we have to modify accordingly.
Also is there any specific reason for using Teamcity and Jenkins simultaneously, unless you are making use of already created Jenkins build?
Steps:
Get CLI based command for Jenkins:
https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI
you can achieve in two ways
Method 1:
As build step is in current build.
Create a build step before your current step and trigger the Jenkins build using CLI
Based on the return value of the Jenkins build step, next step will execute
Method 2:
create a new build with above CLI step and add a dependency in your primary build.
so whenever the primary build is started, it will start the dependent CLI jenkins build. and once the dependent build is completed, will return success/failure, based on that the primary build will start.
i haven't tested the CLI of Jenkins but as Teamcity supports the steps and dependencies structure, expecting this will work.
will keep posted once i implement it.
你可以通過調用某些URL開始詹金斯作業,檢查出https://wiki.jenkins-ci.org/display/JENKINS/參數化+構建部分「使用參數啓動構建」 –