gpt4 book ai didi

git - TeamCity 将参数从服务器传递到构建代理

转载 作者:太空狗 更新时间:2023-10-29 13:10:12 27 4
gpt4 key购买 nike

我想获取构建代理的提交计数以进行手动版本控制,

version = git rev-list --count "branchname"

git 在构建代理上不可用,因为我有“自动在服务器上” checkout 。

有没有办法将 version 从 checkout 服务器传递给构建代理? (不更改 VCS checkout mode 以构建代理)?

我正在运行最新的 9.1.6 版 TC。

最佳答案

Is there a way to pass version from checkout server to build agent? (without changing VCS checkout mode to build agent)?

简短的回答是你做不到

您可以尝试做的是:

- Add a version file to your repository,   
- **before** commiting use a git hook to update this file with the desired number
- Read the content of the file on your build server and you have it.

- Use a git hook to call a job on your build server which gets the
branch name and the number of commits and store it for later use somewhere

Gist 是,既然做不到,就需要有点创意


示例钩子(Hook)可以是:

预接收 Hook

#!/bin/sh

branchName=$1

# Get the number of commits you need to store:
version = git rev-list --count $branchName

#############
# Now write the desired number to the desired file and let
# the build read it
#############

# Output colors
red='\033[0;31m';
green='\033[0;32m';
yellow='\033[0;33m';
default='\033[0;m';

# personal touch :-)
echo "${red}"
echo " "
echo " |ZZzzz "
echo " | "
echo " | "
echo " |ZZzzz /^\ |ZZzzz "
echo " | |~~~| | "
echo " | |- -| / \ "
echo " /^\ |[]+ | |^^^| "
echo " |^^^^^^^| | +[]| | | "
echo " | +[]|/\/\/\/\^/\/\/\/\/|^^^^^^^| "
echo " |+[]+ |~~~~~~~~~~~~~~~~~~| +[]| "
echo " | | [] /^\ [] |+[]+ | "
echo " | +[]+| [] || || [] | +[]+| "
echo " |[]+ | || || |[]+ | "
echo " |_______|------------------|_______| "
echo " "
echo "${default}"

# set the exit code to 0 so the push will occur
exit 0;

关于git - TeamCity 将参数从服务器传递到构建代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36279960/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com