Skip to content

Commit

Permalink
Modified 43.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnu4cn committed Sep 15, 2023
1 parent b34a57d commit 1254e0d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/43_git_skills.md
Expand Up @@ -18,3 +18,31 @@

- 以提交日期顺序列出标签: `git tag --sort=committerdate`


## Jenkins 中检出标签

Jenkins 流水线不会在指定 `agent` 的默认检出源码仓库中,检出标签。而需要在某个阶段中执行以下步骤:


```groovy
stage('checkout_scm') {
environment {
GITHUB_CREDS = credentials('for-github-op')
GIT_SSH_COMMAND = 'ssh -i $GITHUB_CREDS'
}
steps {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])
sh """rm -rf api/ docs/
git submodule update --init --recursive --remote"""
}
}
```

其中的 `checkout` 步骤,就修改了默认检出参数,而指定了检出各个标签。

0 comments on commit 1254e0d

Please sign in to comment.