第一部分有一个易于实施的解决方案,即从 Teamcity 向 Jenkins 发送命令
使用 CURL:
将 Curl 安装/复制到 Teamcity 代理。
然后在您的 TC 构建配置中,创建一个类似于下面的新命令行构建步骤(根据您的需要修改参数)
curl --user %jenkins_user%:%jenkins_pwd% -X POST http://%jenkins_instance_withport%/job/%jenkins_jobs_name%/buildWithParameters?token=%jenkins_token% --data "Build_Number=%build.number%"
例如: curl --user admin:password -X POST http://jenkinssever:2123/job/test-build-image/buildWithParameters?token=rtbuild --data "Build_Number=1.2.0"
在这里我什至可以使用“--data”将内部版本号传递给 Jenkins
在 Jenkins 构建配置下执行以下操作:
在 Jenkins 配置中,更新以下值:
“此项目已参数化”
Name: Build_Number
Default Value: 1.2.0
“触发器远程构建”
Authentication Token: rtbuild
可选:用于设置内部版本号
“设置构建名称”
Build Name: #${Build_numuber}
完成了,您可以开始了。如果您有更多问题,请告诉我。
以上是Initial comment的实现
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.