如何促进从詹金斯的另一个作业的具体​​版本号? [英] How to promote a specific build number from another job in Jenkins?

查看:382
本文介绍了如何促进从詹金斯的另一个作业的具体​​版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了推荐生成插件詹金斯,现在我面临着一些困难,从促进构建现有作业。下面是这种情况:

I installed the Promoted Build Plugin from Jenkins and now I'm facing some troubles to promote a build from an existing job. Here is the scenario:


  1. 有就是每天晚上运行运行所有测试,并且需要度量现有的每夜构建工作;

有一个现有的部署构建接受一个参数$ {BUILD_NUMBER},并部署具有从<$ C对应的$ {BUILD_NUMBER}构建$ C>每夜构建

There is an existing Deploy Build that accepts a parameter ${BUILD_NUMBER} and deploys the build that has the corresponding ${BUILD_NUMBER} from the Nightly Build


  • 说出[每晚构建]跑去成功打造神器#39

  • 现在,我只需运行[部署构建]传递#39作为参数

    • 从[夜间生成]#39会的文物被部署

    到目前为止好。现在是我要添加部分构建促销 ...

    So far so good. Now is the part where I want to add the Build Promotions...

    有没有一种方法,以促进每夜构建#39 通知,在此之前的已建成)从部署构建?或者甚至从别的地方,坦率地说,我真的有种丢在这里:(

    Is there a way to promote the Nightly Build #39 (notice that it was already built before) from the Deploy Build? Or maybe even from somewhere else, quite frankly I`m kind of lost here :(

    我不`吨看到他们有明显的上游/下游关系,因为他们没有一个:始终运行在执行过程中这个版本,然后另一方面 - [部署构建]有时只执行,并不总是[每晚构建]之后的。

    I don`t see them with a clear Upstream/Downstream relationship, because they don't have a: always runs this build and then the other during the execution - the [Deploy Build] is executed sometimes only and not always after the [Nightly Build].

    推荐答案

    随着版本2.23+ <一个href=\"https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin#ParameterizedTriggerPlugin-Backwardcompatibilitywithversion2.22\">behavior改变(感谢 AbhijeetKamble 获得指出)。正在由 predefined参数调用的部分( 建立)作业中存在所谓的(传递的任何参数的部署)工作。此外,所谓的作业参数的限制,因此,如果所谓的作业的参数是一个选择,它必须有所有可能的值(从促销)pre-填充。或者只是使用文本参数类型。

    Update as of version 2.23 of Parameterized Trigger Plugin:

    With version 2.23+ behavior changed (thanks AbhijeetKamble for pointing out). Any parameter that is being passed by Predefined Parameters section of calling (build) job has to exist in the called (deploy) job. Furthermore, the restrictions of called job's parameters apply, so if the called job's parameter is a choice, it has to have all possible values (from promotions) pre-populated. Or just use Text parameter type.

    是的,我有相同的设置:一个的建立的作业(基于SVN提交)和手动执行的部署的工作。当用户选择从的构建的作业(包括老版本)的构建,他们就可以转至促销状态链接,并执行各种的部署的促销活动例如部署到DEV 部署到QA 的等

    Yes, I have the exact same setup: a build job (based on SVN commits) and manually executed deploy job. When the user selects any build from the build job (including older builds), they can then go to Promotion Status link and execute various deploy promotions, for example Deploy to DEV, Deploy to QA, etc


    • 您将需要这些插件:<一href=\"https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin\">Parameterized触发插件推荐构建插件

    • 您还需要设置默认的归档的文物生成后在此建立作业操作。

    • 勾选标记促进建立时

    • 定义的名称部署到DEV

    • 标准复选标记的只有当手动批准

    • 操作使用触发/呼叫建立在其他项目

    • 项目建设输入名称到您的部署的工作在这里

    • 勾选标记阻止,直到触发项目完成他们的建立

    • 标记此版本为失败,如果触发的版本是恶化或等于:失败(根据您的部署工作状态调整)

    • predefined参数(code A)

    • You will need these plugins: Parameterized Trigger Plugin, Promoted Builds Plugin
    • You will also need to setup default Archive the Artifacts post-build action on this build job.
    • Check mark Promote builds when
    • Define Name "Deploy to DEV"
    • Under Criteria check mark Only when manually approved
    • Under Actions use Trigger/call builds on other projects
    • In Projects to build enter the name to your deploy job here
    • Check mark Block until the triggered projects finish their builds
    • Mark this build as failure if the triggered build is worse or equal to: FAILURE (adjust according to statuses of your deploy job)
    • Predefined parameters (Code A)

    code答:

    Server=IP_of_my_dev_server`  
    Job=$PROMOTED_JOB_NAME`  
    BuildSelection=<SpecificBuildSelector><buildNumber>$PROMOTED_NUMBER</buildNumber></SpecificBuildSelector>
    

    以上,在 predefined参数部分,名称为=左边是在你的部署的工作中定义的参数。和=的右侧是本次促销活动执行时将被分配给这些参数的值。定义了三个参数服务器工作 BuildSelection

    Above, in the Predefined parameters section, the name to the left of = are the parameters that are defined in your deploy job. And to the right of = are the values that will be assigned to those parameters when this promotion executes. Defines three parameters Server, Job and BuildSelection.

    参数服务器= 是我自己的,因为我的部署作业可以的部署的多台服务器。但是,如果你的部署的工作很辛苦,codeD始终部署到特定的位置,你就不再需要。

    The parameter Server= is my own, as my deploy job can deploy to multiple servers. However if your deploy job is hardcoded to always deploy to a specific location, you won't need that.

    工作= 参数是必需的,但参数的名称取决于您是什么在你的部署作业设置的(我会说明配置有)。该值 $ PROMOTED_JOB_NAME 必须保持原样。这是一个环境变量,在推广过程中了解并指回的名字您的建立的任务(一个在这里推广过程中配置)

    The Job= parameter is required, but the name of the param depends on what you've setup in your deploy job (I will explain configuration there). The value $PROMOTED_JOB_NAME has to remain as is. This is an environment variable that the promotion process is aware of and refers back to the name of your build job (the one where promotion process is configured)

    是必需的 BuildSelection = 参数。这整个线必须保持原样。传递的值为 $ PROMOTED_NUMBER ,这再次提升是知道的。在你的榜样,这将是#39

    The BuildSelection= parameter is required. This whole line has to remain as is. The value passed is $PROMOTED_NUMBER, which once again the promotion is aware of. In your example, it would be #39.

    阻止,直到触发项目完成他们的建立对勾将推广过程中等到的部署的任务完成了。如果没有,推广过程中会触发部署工作,并成功退出。等待的部署的工作,完成一个好处,如果的部署的作业失败,推广明星将被打上失败了。

    The Block until the triggered projects finish their builds check mark will make the promotion process wait until the deploy job finished. If not, the promotion process will trigger the deployment job and quit with success. Waiting for the deploy job to finish has the benefit that if the deploy job fails, the promotion star will be marked with failure too.

    (一个小注在这里:推广明星将出现成功的,而部署的作业正在运行,如果有一个部署失败,它只会之后更改失败。在部署的任务完成了。逻辑......但如果​​你看看在部署完成)之前的推广明星可以是一个有点混乱

    (One little note here: the promotion star will appear successful while the deploy job is running. If there is a deploy failure, it will only change to failure after the deploy job finished. Logical... but can be a bit confusing if you look at the promotion star before the deployment completed)


    • 您需要 复制文物插件

    • 此版本被参数

    • 名称 服务器(今名配置类型的选择(或文本)的参数必须匹配在推广的 $ p $的配置参数pdefined 在previous部分)

    • 选择:输入将被推广的 $ P $使用可能的服务器IP地址列表pdefined参数在previous节(见下文的更新注)

    • 配置类型的选择(或文本)的参数名称 工作(该名称必须匹配在推广的 $ p $的配置参数pdefined 在previous部分)

    • 选择:输入您的建立的工作作为默认的名称。 <击>这仅如果您手动触发的部署的工作所需。当的部署的作业从推广触发,推广会提供值(即工作= predefined参数,我们配置)。此外,如果没有从推广的 $ P $传递价值pdefined参数,首选值将被使用。如果你之间有1对1的关系的建立的和的部署的工作,你可以省略工作= 促销的配置参数。

    • 更新: since参数触发的2.23版本,可用选项在部署作业配置必须有从推广的predefined参数未来所有可能的值。如果你不希望限制,使用的文本,而不是选择

    • 配置类型的的参数复制神器打造选择名称 BuildSelection

    • 默认选择:最新成功打造

    • 建立步骤

    • 配置从另一个项目复制文物

    • 项目名称输入 $ {工作}

    • 哪个构建选择通过构建参数指定的

    • 参数名称输入 BuildSelection (不包括 $ {...} ! )

    • 相应配置其余为您的工件将从复制的建立的作业的部署的作业的工作区

    • 使用复制文物的部署的内部工作,你需要为了部署

    • You will need Copy Artifacts plugin
    • Under This build is parameterized
    • Configure a parameter of type Choice (or Text) with name Server (this name has to match with configuration in promotion's Predefined Parameters in previous section)
    • Choices: Enter list of possible server IPs that would be used by the promotion's Predefined Parameters in previous section (see update note below)
    • Configure a parameter of type Choice (or Text) with name Job (this name has to match with configuration in promotion's Predefined Parameters in previous section)
    • Choices: Enter the name of your build job as default. This is only needed if you trigger the deploy job manually. When the deploy job is triggered from promotion, the promotion will supply the value (the Job= from Predefined parameters that we configured). Also, if there is no value passed from promotion's Predefined parameters, the first choice value will be used. If you have a 1-to-1 relationship between the build and deploy jobs, you can omit the Job= parameter in promotion's configuration.
    • Update: since version 2.23 of Parameterized Trigger, the available choices in the deploy job configuration have to have all possible values coming from the promotion's predefined parameters. If you don't want that limit, use "Text" instead of "Choice"
    • Configure a parameter of type Build selector for Copy Artifact with name: BuildSelection
    • Default Selector: Latest successful build
    • Under Build steps
    • Configure Copy artifacts from another project
    • In Project name enter ${Job}
    • At Which build choose Specified by a build parameter
    • In Parameter Name enter BuildSelection (without ${...}!)
    • Configure the rest accordingly for your artifacts that will be copied from build job to deploy job's workspace
    • Use the copied artifacts inside the deploy job as you need in order to deploy

    所以,现在,上述的部署的工作,你可以手动运行它,并从的建选择哪个版本号的工作要部署(最后版本,最后成功了,通过版本号等)。你可能已经把它配置非常相似。在推广的上的建立的工作将基本执行同样的事情,并提供版本号的基础上,在执行什么样的推广。

    So now, with the above deploy job, you can run it manually and select which build number from build job you want to deploy (last build, last successful, by build number, etc). You probably already have it configured very similarly. The promotion on the build job will basically execute the same thing, and supply the build number, based on what promotion was executed.

    让我知道如果你有任何问题的说明。

    Let me know if you got any issues with the instructions.

    这篇关于如何促进从詹金斯的另一个作业的具体​​版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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