2017-08-29 42 views
0

目前,我們正在使用GitLab Enterprise Edition 9.5.1和TeamCity Professional 2017.1.2(build 46812)。構建代理具有類似如何強制TeamCity僅對GitLab中的簽名提交工作

git pull --verify-signature

我們組一行想擁有的TeamCity,而無需顯式pull命令驗證GPG簽名。

你如何配置TeamCity來做到這一點?

回答

0

社區缺乏意見,這裏是第一個工作kludge。

首先生成步驟

在第一TeamCity的構建步驟的第一行是:

git verify-commit HEAD~0 

export VERIFY_EXIT_CODE=$? 

if [ "$VERIFY_EXIT_CODE" -eq "0" ] 
then 
    echo "Git commit GPG signature is VERIFIED" 
else 
    echo "Git commit GPG signature is NOT VERIFIED" 
    build stop 
fi 

GPG簽名驗證

當提交具有驗證GPG簽名,輸出類似於此:

[12:17:54] Step 1/3: Verify GPG signature on commit (Command Line) 
[12:17:54][Step 1/3] Starting: /home/*******/Applications/TeamCity/buildAgent_***_1/temp/agentTmp/custom_script5468853061762530637 
[12:17:54][Step 1/3] in directory: /home/*******/Applications/TeamCity/buildAgent_***_1/work/c8edabae02b7df61 
[12:17:54][Step 1/3] 
[12:17:54][Step 1/3] git verify-commit HEAD~0 
[12:17:54][Step 1/3] gpg: Signature made Tue 05 Sep 2017 12:15:59 PM MDT using RSA key ID 71F1FCB8 
[12:17:54][Step 1/3] gpg: Good signature from "My Name (*** gpg key) <******@*****.***>" 
[12:17:54][Step 1/3] 
[12:17:54][Step 1/3] export VERIFY_EXIT_CODE=$?=0 
[12:17:54][Step 1/3] Git commit GPG signature is VERIFIED 
[12:17:54][Step 1/3] Process exited with code 0 

GPG簽名未驗證

當提交沒有驗證GPG簽名,或TeamCity的找不到公鑰,輸出看起來是這樣的:

[12:10:37] Step 1/3: Verify gpg signature on git repository (Command Line) 
[12:10:37][Step 1/3] Starting: /home/*******/Applications/TeamCity/buildAgent_***_1/temp/agentTmp/custom_script4984466249864504039 
[12:10:37][Step 1/3] in directory: /home/*******/Applications/TeamCity/buildAgent_***_1/work/c8edabae02b7df61 

[12:10:37][Step 1/3] git verify-commit HEAD~0 
[12:10:37][Step 1/3] Git repository is NOT VERIFIED 
[12:10:37][Step 1/3] 
[12:10:37][Step 1/3] export VERIFY_EXIT_CODE=$?=1 
[12:10:37][Step 1/3] Git repository is NOT VERIFIED 
[12:10:37][Step 1/3] 
[12:10:37][Step 1/3] build stop 
[12:10:37][Step 1/3] /home/*******/Applications/TeamCity/buildAgent_***_1/temp/agentTmp/custom_script4984466249864504039: line 19: build: command not found 
[12:10:37][Step 1/3] Process exited with code 127 
[12:10:37][Step 1/3] Process exited with code 127 
[12:10:37][Step 1/3] Step Verify gpg signature on git repository (Command Line) failed 
[12:10:37][Step 1/3] Error message is logged