質問編集履歴

1

追記

2017/07/06 11:57

投稿

ngyuki
ngyuki

スコア4514

test CHANGED
File without changes
test CHANGED
@@ -71,3 +71,101 @@
71
71
 
72
72
 
73
73
  Pipeline プロジェクト単体で、複数のノードにチェックアウトするときに同じコミットが使われるようにすることはできないものでしょうか?
74
+
75
+
76
+
77
+ ---
78
+
79
+
80
+
81
+ **追記**
82
+
83
+
84
+
85
+ ↑の Jenkinsfile で Pipeline プロジェクト単体のときは下記のように、
86
+
87
+
88
+
89
+ ```
90
+
91
+ > git rev-parse --is-inside-work-tree # timeout=10
92
+
93
+ Fetching changes from the remote Git repository
94
+
95
+ > git config remote.origin.url git@git.example.com:ore/are.git # timeout=10
96
+
97
+ Pruning obsolete local branches
98
+
99
+ Fetching upstream changes from git@git.example.com:ore/are.git
100
+
101
+ > git --version # timeout=10
102
+
103
+ using GIT_SSH to set credentials
104
+
105
+ > git fetch --tags --progress git@git.example.com:ore/are.git +refs/heads/*:refs/remotes/origin/* --prune
106
+
107
+ > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
108
+
109
+ > git rev-parse refs/remotes/origin/refs/heads/master^{commit} # timeout=10
110
+
111
+ Checking out Revision 4043d3de1b7e92c87c1a5ca0b610f4b0305907ea (refs/remotes/origin/master)
112
+
113
+ Commit message: "hoge"
114
+
115
+ > git config core.sparsecheckout # timeout=10
116
+
117
+ > git checkout -f 4043d3de1b7e92c87c1a5ca0b610f4b0305907ea
118
+
119
+ ```
120
+
121
+
122
+
123
+ フリースタイルの Parameterized Trigger からコミットを渡したときは下記のように、
124
+
125
+
126
+
127
+ ```
128
+
129
+ > git rev-parse --is-inside-work-tree # timeout=10
130
+
131
+ Fetching changes from the remote Git repository
132
+
133
+ > git config remote.origin.url git@git.example.com:ore/are.git # timeout=10
134
+
135
+ Pruning obsolete local branches
136
+
137
+ Fetching upstream changes from git@git.example.com:ore/are.git
138
+
139
+ > git --version # timeout=10
140
+
141
+ using GIT_SSH to set credentials
142
+
143
+ > git fetch --tags --progress git@git.example.com:ore/are.git +refs/heads/*:refs/remotes/origin/* --prune
144
+
145
+ Checking out Revision d8a913b5b5741a06488bb39ebad0620f9911431c (refs/remotes/origin/master)
146
+
147
+ Commit message: "hoge"
148
+
149
+ > git config core.sparsecheckout # timeout=10
150
+
151
+ > git checkout -f d8a913b5b5741a06488bb39ebad0620f9911431c
152
+
153
+ ```
154
+
155
+
156
+
157
+ 前者は下記のようにブランチ名からコミットIDを特定しているのに対して、後者はいきなりコミットID指定でチェックアウトされています。
158
+
159
+
160
+
161
+ ```
162
+
163
+ > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
164
+
165
+ > git rev-parse refs/remotes/origin/refs/heads/master^{commit} # timeout=10
166
+
167
+ ```
168
+
169
+
170
+
171
+ 前者と後者では `checkout(scm)` の `scm` にチェックアウトすべきコミットIDが設定されているかどうかの違いのように思うので、なんらかの方法でビルドのトリガとなったコミットのIDを Jenkinsfile の中で取得して `scm` に設定してらればいいような気はしているのですが。。。