teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

追記

2017/07/06 11:57

投稿

ngyuki
ngyuki

スコア4516

title CHANGED
File without changes
body CHANGED
@@ -34,4 +34,53 @@
34
34
 
35
35
  いろいろ試行錯誤したところ、フリースタイルプロジェクトで Parameterized Trigger を使って、Pipeline プロジェクトへ **Pass through Git Commit that was built** でコミットを渡すと↑の Jenkinsfile でもすべての `checkout(scm)` で同じコミットをチェックアウトさせられることはわかりました。が、できれば Pipeline プロジェクト単体でやりたいと思っています。
36
36
 
37
- Pipeline プロジェクト単体で、複数のノードにチェックアウトするときに同じコミットが使われるようにすることはできないものでしょうか?
37
+ Pipeline プロジェクト単体で、複数のノードにチェックアウトするときに同じコミットが使われるようにすることはできないものでしょうか?
38
+
39
+ ---
40
+
41
+ **追記**
42
+
43
+ ↑の Jenkinsfile で Pipeline プロジェクト単体のときは下記のように、
44
+
45
+ ```
46
+ > git rev-parse --is-inside-work-tree # timeout=10
47
+ Fetching changes from the remote Git repository
48
+ > git config remote.origin.url git@git.example.com:ore/are.git # timeout=10
49
+ Pruning obsolete local branches
50
+ Fetching upstream changes from git@git.example.com:ore/are.git
51
+ > git --version # timeout=10
52
+ using GIT_SSH to set credentials
53
+ > git fetch --tags --progress git@git.example.com:ore/are.git +refs/heads/*:refs/remotes/origin/* --prune
54
+ > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
55
+ > git rev-parse refs/remotes/origin/refs/heads/master^{commit} # timeout=10
56
+ Checking out Revision 4043d3de1b7e92c87c1a5ca0b610f4b0305907ea (refs/remotes/origin/master)
57
+ Commit message: "hoge"
58
+ > git config core.sparsecheckout # timeout=10
59
+ > git checkout -f 4043d3de1b7e92c87c1a5ca0b610f4b0305907ea
60
+ ```
61
+
62
+ フリースタイルの Parameterized Trigger からコミットを渡したときは下記のように、
63
+
64
+ ```
65
+ > git rev-parse --is-inside-work-tree # timeout=10
66
+ Fetching changes from the remote Git repository
67
+ > git config remote.origin.url git@git.example.com:ore/are.git # timeout=10
68
+ Pruning obsolete local branches
69
+ Fetching upstream changes from git@git.example.com:ore/are.git
70
+ > git --version # timeout=10
71
+ using GIT_SSH to set credentials
72
+ > git fetch --tags --progress git@git.example.com:ore/are.git +refs/heads/*:refs/remotes/origin/* --prune
73
+ Checking out Revision d8a913b5b5741a06488bb39ebad0620f9911431c (refs/remotes/origin/master)
74
+ Commit message: "hoge"
75
+ > git config core.sparsecheckout # timeout=10
76
+ > git checkout -f d8a913b5b5741a06488bb39ebad0620f9911431c
77
+ ```
78
+
79
+ 前者は下記のようにブランチ名からコミットIDを特定しているのに対して、後者はいきなりコミットID指定でチェックアウトされています。
80
+
81
+ ```
82
+ > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
83
+ > git rev-parse refs/remotes/origin/refs/heads/master^{commit} # timeout=10
84
+ ```
85
+
86
+ 前者と後者では `checkout(scm)` の `scm` にチェックアウトすべきコミットIDが設定されているかどうかの違いのように思うので、なんらかの方法でビルドのトリガとなったコミットのIDを Jenkinsfile の中で取得して `scm` に設定してらればいいような気はしているのですが。。。