[英]Git checkout in Jenkins pipeline misses commit's tag
我的Jenkins管道作業之一應考慮當前正在構建的提交上的標記。 但是似乎最頂層提交上的標簽在構建時不可用。
假設我有三個提交的簡單歷史記錄:
my_commit_to_build (tagged v2)
|
v
another_commit (tagged v1)
|
v
initial_commit
我的管道腳本包含以下結帳步驟:
checkout(
changelog: false,
poll: false,
scm: [
$class : 'GitSCM',
userRemoteConfigs: [
[
url : <SCM_URL>,
credentialsId: <CREDENTIALS_ID>,
refspec : <REFSPEC_TO_BUILD>
]
],
branches : [
[
name: <REFSPEC_TO_BUILD>
]
],
extensions : [
[$class: 'BuildChooserSetting', buildChooser: [$class: 'GerritTriggerBuildChooser']],
[$class: 'LocalBranch', localBranch: <LOCAL_BRANCH_NAME>],
[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
[$class: 'PruneStaleBranch'],
[$class: 'CleanCheckout']
]
]
)
這導致作業運行以下命令:
Cloning the remote Git repository
Cloning repository <SCM_URL>
> git init /home/jenkins/workspace/<WORKSPACE> # timeout=10
Fetching upstream changes from <SCM_URL>
> git --version # timeout=10
using GIT_SSH to set credentials SSH Key for <USER>
> git fetch --tags --progress <SCM_URL> +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url <SCM_URL> # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url <SCM_URL> # timeout=10
Pruning obsolete local branches
Fetching upstream changes from <SCM_URL>
using GIT_SSH to set credentials SSH Key for <USER>
> git fetch --tags --progress <SCM_URL> --prune
> git rev-parse <REV>^{commit} # timeout=10
Checking out Revision <REV> (<LOCAL_BRANCH_NAME>)
> git config core.sparsecheckout # timeout=10
> git checkout -f <REV>
> git branch -a -v --no-abbrev # timeout=10
> git checkout -b <LOCAL_BRANCH_NAME> <REV>
Commit message: "my_commit_to_build"
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
現在,當我檢查存儲庫的本地副本中歷史記錄中最上面的提交和最后一次提交時的標記時,將得到以下信息:
> git --no-pager tag -l --points-at=HEAD
> git describe --abbrev=0 --tags
v1
> ...
我已經嘗試prune
fetch命令和sparse
簽出中刪除prune
,但是兩者都沒有幫助(無論如何,我對這兩個都沒有希望...)。
有誰知道我應該如何調整我的結帳步驟,以便在構建標簽時可用?
提前致謝!
作為注釋,這可能會更好,但是我還不能添加它們。
除了BuildChooserSetting之外,我在具有相同擴展名的類似存儲庫上進行了測試,並且按預期工作。
您確定要簽出的分支包含該標簽嗎? 另外, git tag
的輸出是什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.