Jenkins:如何使用参数化触发器插件并通过Subversion修订版? [英] Jenkins: How do I use the Parameterized Trigger Plugin and pass a subversion revision?

查看:98
本文介绍了Jenkins:如何使用参数化触发器插件并通过Subversion修订版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IMO,此用例确实需要在插件的网页/文档中特别说明.

IMO, this use case really needs to be specifically spelled out on the plugin's webpage/documentation.

比方说,我有一个名为U的项目,上游.当U完成构建后,我希望D签出与U刚刚构建的修订版相同的版本. U将始终结帐HEAD.

Let's say I have a project named U for upstream and D for downstream. When U finishes building, I want D to checkout the same revision that U just built. U will always checkout HEAD.

这就是我所做的:

  1. 在U中,我为在其他项目上触发参数化的构建"添加了构建后操作".
  2. 对于要构建的项目",我输入D并仅在稳定"时构建.
  3. 我为"Subversion修订版"添加了一个触发器.
  4. 我保存了此配置

现在我不知道下一步该怎么做,但是我没有得到 feedback 来表明这是可行的.实际上,即使是这个测试用例,致力于插件源,这就是我应该做的所有事情.

Now I don't know what I'm supposed to do next, but I get no feedback to indicate this is working. In fact, even this testcase that's committed to the plugin source suggests this is all I should have to do.

但是,如果我猜到了,我认为我应该将U标记为参数化的版本,并为其添加一个参数.此参数应命名为U发送给D的名称.但是,如果我有正确的主意,则不知道该为该参数命名的内容. D的控制台日志或U的控制台日志都未提及任何新参数.

But, if I were to guess, I'd think I'm supposed to mark U as a parameterized build and add a parameter to it. This parameter should be named what U sends to D. But, if I've got the right idea, I don't know what I'm supposed to name this parameter. Neither the console log of D nor the console log of U mentions any new parameter.

我猜了一下,并在U中创建了一个名为"SVN_REVISION"的String参数,并将其默认设置为-1,但这没有任何效果.每次D触发构建时,SVN_REVISION默认为-1.

I took a guess and created a String parameter in U named "SVN_REVISION" and defaulted it to -1, but that had no effect. Every time D triggers a build, SVN_REVISION is defaulted to -1.

这是在D项目上运行export的输出:

This is the output of running export on the D project:

+ export
export BUILD_ID="2013-03-20_09-48-32"
export BUILD_NUMBER="4522"
export BUILD_TAG="jenkins-D-4522"
export BUILD_URL="http://my.jenkins.server.com:8081/job/D/4522/"
export EXECUTOR_NUMBER="2"
export HUDSON_COOKIE="8ec52f7a-d60d-4640-83a9-dbed7351b32a"
export HUDSON_HOME="/opt/hudson"
export HUDSON_SERVER_COOKIE="633967fcd1d6f7b38a85042ada5c3949"
export HUDSON_URL="http://my.jenkins.server.com:8081/"
export JAVA_HOME="/opt/java"
export JENKINS_HOME="/opt/hudson"
export JENKINS_SERVER_COOKIE="633967fcd1d6f7b38a85042ada5c3949"
export JENKINS_URL="http://my.jenkins.server.com:8081/"
export JOB_NAME="D"
export JOB_URL="http://my.jenkins.server.com:8081/job/D/"
export LANG="en_US.UTF-8"
export LD_LIBRARY_PATH="/opt/jdk1.6.0_30/jre/lib/i386/server:/opt/jdk1.6.0_30/jre/lib/i386:/opt/jdk1.6.0_30/jre/../lib/i386"
export M2="/opt/maven/bin"
export M2_HOME="/opt/maven"
export MAVEN_OPTS="-Xms256m -Xmx512m"
export NHINC_PROPERTIES_DIR="/opt/nhinc/Properties"
export NLSPATH="/usr/dt/lib/nls/msg/%L/%N.cat"
export NODE_LABELS="master"
export NODE_NAME="master"
export OLDPWD
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/opt/java/bin:/opt/apache-ant-1.8.1/bin:/usr/local/bin:/opt/maven/bin"
export PWD="/opt/hudson/jobs/D/workspace"
export SHLVL="2"
export SVN_REVISION="24186"
export SVN_URL="https://a/url/trunk"
export TERM="xterm"
export WORKSPACE="/opt/hudson/jobs/D/workspace"
export XFILESEARCHPATH="/usr/dt/app-defaults/%L/Dt"
export _="/opt/java/bin/java"

因此,它似乎具有SVN_REVISION环境变量.但是我认为这不一定来自插件.我的证据来自jenkins中存储库URL"上的描述:

So it looks like it has an SVN_REVISION environment variable. But I don't think that's necessarily coming from the plugin. My evidence comes from the description on the "Repository URL" in jenkins:

在构建期间,已检出模块的修订版号 可通过环境变量SVN_REVISION获得,提供 您只签出一个模块.如果您有多个 检出的模块,请使用svnversion命令.如果您有多个 模块检出,您可以使用svnversion命令获取 版本信息,或者您可以使用SVN_REVISION_环境 变量,其中与位置匹配的从1开始的索引 配置.这些网址可通过类似的SVN_URL_获得 环境变量.

During the build, revision number of the module that was checked out is available through the environment variable SVN_REVISION, provided that you are only checking out one module. If you have multiple modules checked out, use the svnversion command. If you have multiple modules checked out, you can use the svnversion command to get the revision information, or you can use the SVN_REVISION_ environment variables, where is a 1-based index matching the locations configured. The URLs are available through similar SVN_URL_ environment variables.

但是让我们假设这是从U而不是D设置的.我如何使D使用它,或者当D被触发时如何知道它正在使用它?

But lets assume this is being set from U instead of D. How do I make D use that or how do I know it's using it when D gets triggered?

让我问一个问题,我接下来可能要问.知道需要使用的参数名称后,如何修改D的配置以使它签出该修订版?我是否修改存储库URL"以在末尾放置@${PARAMETER_NAME}或其他内容?

Let me ask a question that I'll probably need to ask next. Once I know the name of the parameter I need to use, how do I modify the configuration of D so that it checks out that revision? Do I modify the "Repository URL" to put a @${PARAMETER_NAME} at the end or something?

推荐答案

结果,

Turns out, like the test case says, this was all I had to do. I tested this by committing to U, then committed again while it was building. Once D started building, it grabbed the first commit, not the latest. That's how I tested it was working.

希望能提供更好的反馈,但至少我知道它是有效的.

Better feedback would be appreciated, but at least I know it's working.

这篇关于Jenkins:如何使用参数化触发器插件并通过Subversion修订版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆