zoukankan      html  css  js  c++  java
  • jenkins学习10-参数化构建(构建git仓库分支)

    前言

    当我们的自动化项目越来越多的时候,在代码仓库会提交不同的分支来管理,在用jenkins来构建的时候,我们希望能通过参数化构建git仓库的分支。

    Git Parameter插件

    先下载 Git Parameter 插件,系统管理-插件管理-搜索:Git Parameter 下载安装

    安装完成

    参数化构建工程

    General-参数化构建过程-添加参数-Git Parameter,

    填写 Git Parameter 参数配置

    • Name 自定义参数名称
    • Description 描述
    • Paramert Type 参数类型,可选 Tag 、Branch 、Branch or Tag、Revision、Pull Request
    • Default Value 默认值

    指定分支引用上面的变量:${branch}

    参数化构建

    保存成功后,在job列表页,构建的时候,可以选择- Build with Parameters

    接着会自动加载出项目的所有分支,可供选择

    勾选其中一个分支就可以构建了,构建完成后可以看控制台输出日志

    Started by user admin
    Running as SYSTEM
    Building in workspace /var/jenkins_home/workspace/pytest_demo
    using credential c7f48895-1166-45c5-a066-582c7ffa1111
     > git rev-parse --is-inside-work-tree # timeout=10
    Fetching changes from the remote Git repository
     > git config remote.origin.url https://github.com/yoyoketang/pytest_jenkins_demo.git # timeout=10
    Fetching upstream changes from https://github.com/yoyoketang/pytest_jenkins_demo.git
     > git --version # timeout=10
    using GIT_ASKPASS to set credentials 
     > git fetch --tags --progress -- https://github.com/yoyoketang/pytest_jenkins_demo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
     > git rev-parse refs/remotes/origin/yoyoketang^{commit} # timeout=10
     > git rev-parse refs/remotes/origin/origin/yoyoketang^{commit} # timeout=10
    Checking out Revision 2932c8cfff11ed08d5c44d207d8b72d83917fb63 (refs/remotes/origin/yoyoketang)
     > git config core.sparsecheckout # timeout=10
     > git checkout -f 2932c8cfff11ed08d5c44d207d8b72d83917fb63 # timeout=10
    Commit message: "新增yoyoketang"
    

    从日志看出,构建时候拉取到的分支是:/remotes/origin/yoyoketang

  • 相关阅读:
    Pytest 系列(28)- 参数化 parametrize + @allure.title() 动态生成标题
    Pytest 系列(27)- allure 命令行参数
    Pytest 系列(26)- 清空 allure 历史报告记录
    Pytest 系列(25)- 标记用例级别 @allure.
    Pytest 系列(24)- allure 环境准备
    基于Python的三种Bandit算法的实现
    博客迁移
    团体程序设计天梯赛2020游记
    P1825 [USACO11OPEN]Corn Maze S
    # JavaScript中的对象转数组Array.prototype.slice.call()方法详解
  • 原文地址:https://www.cnblogs.com/yoyoketang/p/12514618.html
Copyright © 2011-2022 走看看