0
1

More than 1 year has passed since last update.

jenkins:submoduleまでまとめて取得する(pipeline)

Posted at

簡易チェックアウト

簡易チェックアウトの場合は、こう

git branch: branch_name, url: GIT_URL, credentialsId: credentialsID

ただ、この場合タイムアウト10分で設定されているため、10分超えるクローンや、pullだとエラーになってしまう。
また、サブモジュールの取得まではできないので、GitSCMを推奨する。

細かく色々設定してGitチェックアウト

checkout([$class: 'GitSCM',
                branches: [[name: branch_name]],
                    extensions: [
                        [$class: 'CloneOption', timeout: git_timeout],
                        [$class: 'CheckoutOption', timeout: git_timeout]
                    ],
                    doGenerateSubmoduleConfigurations: false,
                    extensions: [[$class: 'SubmoduleOption',
                                    disableSubmodules: false,
                                    parentCredentials: true,
                                    recursiveSubmodules: true,
                                    reference: '',
                                    trackingSubmodules: false]],
                    submoduleCfg: [],
                gitTool: 'Default',
                userRemoteConfigs: [[credentialsId: credentialsID, url: GIT_URL]]
            ])

gi_timeoutは、変数値でも直値でもいける。
parentCredentialsは、親のcredentials使ってアクセスするか、なので基本true.
recursiveSubmodulesは、再起的に取りに行くか。色々操作しないならそのままtrue.

def git_info = checkout([$class....

とすると、返ってきたgit_infoで、gitの環境変数に色々アクセスできる。

Environment Variables

The git plugin assigns values to environment variables in several contexts. >Environment variables are assigned in Freestyle, Pipeline, Multibranch Pipeline, >and Organization Folder projects.
Branch Variables

GIT_BRANCH

Name of branch being built including remote name, as in origin/master
GIT_LOCAL_BRANCH

Name of branch being built without remote name, as in master

Commit Variables

GIT_COMMIT

SHA-1 of the commit used in this build
GIT_PREVIOUS_COMMIT

SHA-1 of the commit used in the preceding build of this project
GIT_PREVIOUS_SUCCESSFUL_COMMIT

SHA-1 of the commit used in the most recent successful build of this project

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1