我意识到gitlab CI似乎不允许多个refs
。只会先走。
例如,对于以下说明,merge_requests
将被忽略,并在直接更新开发分支时触发。
face-build:
stage: build
image: docker:19.03.8
services:
- docker:19.03.8-dind
script:
- sh some-scripts.sh
only:
refs:
- /^develop$/
- merge_requests
如果我将merge_requests
交换到/^develop$/
之前,则会为所有合并请求触发。
反正有两种设置都有效吗?
答案 0 :(得分:1)
如果您使用的是GitLab 12.3或更高版本,请尝试使用rules:if
子句,而不要使用def vgg_16():
b_model = VGG16(weights='imagenet', include_top=False)
x = b_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(256, activation=activation)(x)
predictions = Dense(1, activation='sigmoid')(x)
model = Model(inputs=b_model.input, outputs=predictions)
for layer in model.layers[:15]: #
layer.trainable = False
opt = SGD(lr=init_lr, nesterov=True)
model.compile(loss='binary_crossentropy', optimizer=opt, metrics=['accuracy'])
return model
main_model = vgg_16()
history = main_model.fit(X_train, y_train, batch_size=batch_size,
epochs=EPOCHS, validation_data=(X_test, y_test), verbose=1,
callbacks=[es, mc, l_r])
:
only
请选中Rules attributes,以便为face-build:
stage: build
image: docker:19.03.8
services:
- docker:19.03.8-dind
script:
- sh some-scripts.sh
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^develop$/'
when: always
(when
,on_success
,always
或delayed
)选择最合适的值。