{"id":48,"date":"2023-03-14T11:24:37","date_gmt":"2023-03-14T03:24:37","guid":{"rendered":"http:\/\/idc.birk.cn\/?p=48"},"modified":"2023-03-14T14:44:30","modified_gmt":"2023-03-14T06:44:30","slug":"48","status":"publish","type":"post","link":"https:\/\/idc.birk.cn\/?p=48","title":{"rendered":"gitlab-ci.yml\u5173\u952e\u8bcd\u5b8c\u6574\u89e3\u6790"},"content":{"rendered":"\n<p>\u4f7f\u7528GitLab\u81ea\u5e26\u7684\u6d41\u6c34\u7ebf\uff0c\u5fc5\u987b\u8981\u5b9a\u4e49\u6d41\u6c34\u7ebf\u7684\u5185\u5bb9\uff0c\u800c\u5b9a\u4e49\u5185\u5bb9\u7684\u6587\u4ef6\u9ed8\u8ba4\u53eb\u505a<code>.gitlab-ci.yml<\/code>\uff0c\u4f7f\u7528yml\u7684\u8bed\u6cd5\u8fdb\u884c\u7f16\u5199\u3002 \u76ee\u524d\u4efb\u52a1\u5173\u952e\u8bcd\u670928\u4e2a\uff0c\u5168\u5c40\u7684\u5173\u952e\u8bcd\u670910\u4e2a\uff0c\u4e24\u8005\u91cd\u53e0\u7684\u6709\u5f88\u591a\u3002\u4eca\u5929\u6211\u7ed9\u5927\u5bb6\u5148\u8bb2\u89e3\u4e00\u4e0b\u5e38\u7528\u7684\u5173\u952e\u8bcd\uff0c\u638c\u63e1\u4e86\u8fd9\u4e9b\u5173\u952e\u8bcd\u7684\u7528\u6cd5\uff0c\u4f60\u53ef\u4ee5\u7f16\u5199\u903b\u8f91\u4e25\u8c28\uff0c\u6613\u4e8e\u6269\u5c55\u7684\u6d41\u6c34\u7ebf\u3002<\/p>\n\n\n\n<p>\u4efb\u52a1\u768428\u4e2a\u5173\u952e\u8bcd\u5206\u522b\u662f,&nbsp;<code>script<\/code>,&nbsp;<code>after_script<\/code>,&nbsp;<code>allow_failure<\/code>,&nbsp;<code>artifacts<\/code>,&nbsp;<code>before_script<\/code>,&nbsp;<code>cache<\/code>,&nbsp;<code>coverage<\/code>,&nbsp;<code>dependencies<\/code>,&nbsp;<code>environment<\/code>,&nbsp;<code>except<\/code>,&nbsp;<code>extends<\/code>,&nbsp;<code>image<\/code>,&nbsp;<code>include<\/code>,&nbsp;<code>interruptible<\/code>,&nbsp;<code>only<\/code>,&nbsp;<code>pages<\/code>,&nbsp;<code>parallel<\/code>,&nbsp;<code>release<\/code>,&nbsp;<code>resource_group<\/code>,&nbsp;<code>retry<\/code>,&nbsp;<code>rules<\/code>,&nbsp;<code>services<\/code>,&nbsp;<code>stage<\/code>,&nbsp;<code>tags<\/code>,&nbsp;<code>timeout<\/code>,&nbsp;<code>trigger<\/code>,&nbsp;<code>variables<\/code>,&nbsp;<code>when<\/code><\/p>\n\n\n\n<p>\u5168\u5c40\u7684\u5173\u952e\u8bcd&nbsp;<code>image\uff0cservices\uff0cbefore_script\uff0cafter_script\uff0ctags\uff0ccache\uff0cartifacts\uff0cretry\uff0ctimeout\uff0cinterruptible<\/code><\/p>\n\n\n\n<p>\u6700\u5e38\u4efb\u52a1\u4e2d\u6700\u5e38\u7528\u7684\u662f\u8fd9\u4e03\u4e2a<code>script<\/code>\uff0c<code>artifacts<\/code>\uff0c<code>stage<\/code>\uff0c&nbsp;<code>when<\/code>\uff0c<code>tags<\/code>\uff0c<code>image<\/code>\uff0c<code>cache<\/code>\uff0c \u4e0b\u9762\u6211\u5148\u6765\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e0b\u8fd9\u4e03\u4e2a\u5173\u952e\u8bcd\uff0c\u77e5\u9053\u4e86\u8fd9\u4e2a\u4e03\u4e2a\u5173\u952e\u8bcd\uff0c\u4e00\u822c\u7684\u6d41\u6c34\u7ebf\u968f\u968f\u4fbf\u4fbf\u62ff\u4e0b\uff0c<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/README.html#script\">script<\/a><\/p>\n\n\n\n<p>\u4efb\u52a1\u8981\u6267\u884c\u7684shell\u811a\u672c\u5185\u5bb9\uff0c\u5185\u5bb9\u4f1a\u88abrunner\u6267\u884c\uff0c\u5728\u8fd9\u91cc\uff0c\u4f60\u4e0d\u9700\u8981\u4f7f\u7528<code>git clone ....<\/code>\u514b\u9686\u5f53\u524d\u7684\u9879\u76ee\uff0c\u6765\u8fdb\u884c\u64cd\u4f5c\uff0c\u56e0\u4e3a\u5728\u6d41\u6c34\u7ebf\u4e2d\uff0c\u6bcf\u4e00\u4e2a\u7684job\u7684\u6267\u884c\u90fd\u4f1a\u5c06\u9879\u76ee\u4e0b\u8f7d\uff0c\u6062\u590d\u7f13\u5b58\u8fd9\u4e9b\u6d41\u7a0b\uff0c\u4e0d\u9700\u8981\u4f60\u518d\u4f7f\u7528\u811a\u672c\u6062\u590d\u3002\u4f60\u53ea\u9700\u8981\u5728\u8fd9\u91cc\u5199\u4f60\u7684\u9879\u76ee\u5b89\u88c5\uff0c\u7f16\u8bd1\u6267\u884c\uff0c\u5982&nbsp;<code>npm install<\/code>&nbsp;\u53e6\u5916\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u811a\u672c\u7684\u5de5\u4f5c\u76ee\u5f55\u5c31\u662f\u5f53\u524d\u9879\u76ee\u7684\u6839\u76ee\u5f55\uff0c\u6240\u6709\u53ef\u4ee5\u5c31\u50cf\u5728\u672c\u5730\u5f00\u53d1\u4e00\u6837\u3002\u6b64\u5916script\u53ef\u4ee5\u662f\u5355\u884c\u6216\u8005\u591a\u884c<\/p>\n\n\n\n<p>\u5355\u884c\u811a\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>job<\/em>:<em>  scri<\/em>pt: npm install<\/code><\/pre>\n\n\n\n<p>\u591a\u884c\u811a\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>job<\/em>:<em>  scri<\/em>pt:<em>    <\/em>- npm config set sass_binary_site https:\/\/npm.taobao.org\/mirrors\/node-sass\/<em>    <\/em>- npm install --registry=http:\/\/registry.npm.taobao.org<\/code><\/pre>\n\n\n\n<p>***script***\u662f\u4e00\u4e2ajob\u7684\u5fc5\u586b\u5185\u5bb9\uff0c\u4e0d\u53ef\u6216\u7f3a\u3002\u4e00\u4e2ajob\u6700\u5c11\u6709\u4e8c\u4e2a\u5c5e\u6027\uff0c\u4e00\u4e2a\u662fjob name\uff0c \u4efb\u52a1\u540d\u79f0\uff0c \u4e00\u4e2a\u5c31\u662fscript\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/README.html#image\">image<\/a><\/p>\n\n\n\n<p>\u6307\u5b9a\u4e00\u4e2a\u57fa\u7840<a href=\"https:\/\/cloud.tencent.com\/product\/tke?from=10680\">Docker<\/a>\u955c\u50cf\u4f5c\u4e3a\u57fa\u7840\u8fd0\u884c\u73af\u5883\uff0c\u7ecf\u5e38\u7528\u5230\u7684\u955c\u50cf\u6709<code>node<\/code>&nbsp;<code>nginx<\/code>&nbsp;<code>docker<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>job<\/em>:<em>  imag<\/em>e: node:latest<em>  scri<\/em>pt: npm install<\/code><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762\u8fd9\u4e2a\u4efb\u52a1\u4e2d\uff0c\u5982\u679c\u4e0d\u6307\u5b9a<code>image: node:latest<\/code>&nbsp;\u6267\u884c\u4e0b\u9762\u7684<code>npm install<\/code>\u65f6\u4f1a\u62a5\u9519\uff0c\u627e\u4e0d\u5230<code>npm<\/code>\u7684\u547d\u4ee4\u3002 image\u7684\u4f5c\u7528\u5c31\u662f\u7ed9\u5f53\u524d\u4efb\u52a1\u6216\u8005\u5f53\u524d\u6d41\u6c34\u7ebf\u8bbe\u7f6e\u4e00\u4e2a\u57fa\u7840\u73af\u5883\uff0c\u6709\u53ef\u80fd\u662fnodejs\uff0c\u4e5f\u6709\u53ef\u80fd\u662fjava\uff0c go\uff0c php\uff0c \u53ef\u4ee5\u8bbe\u7f6e\u5f53\u524d\u6d41\u6c34\u7ebf\u7684\uff0c\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u5f53\u524d\u4efb\u52a1\u7684\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/README.html#artifacts\">artifacts<\/a><\/p>\n\n\n\n<p>\u7ffb\u8bd1\u51fa\u6765\u8fd9\u4e2a\u5355\u8bcd\u5c31\u662f\u5236\u54c1\uff0c\u4e00\u4e2a\u6210\u54c1\uff0c\u4f5c\u7528\u662f\u5c06\u6d41\u6c34\u7ebf\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e9b\u6587\u4ef6\uff0c\u6587\u4ef6\u5939\uff0c\u6253\u5305\u538b\u7f29\uff0c\u63d0\u4f9b\u4e00\u4e2a\u5916\u94fe\u4f9b\u4eba\u4e0b\u8f7d\uff0c\u53e6\u5916\u8fd8\u80fd\u5728\u540e\u7eed\u7684job\u4e2d\u7f13\u5b58\u3002 \u6bd4\u5982\u6211\u4eec\u6784\u5efa\u4e00\u4e2a\u524d\u7aef\u9879\u76ee\u540e\u5c06dist\u76ee\u5f55\u505a\u6210\u4e00\u4e2a\u538b\u7f29\u5305\uff0c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>build<\/em>:<em>  scri<\/em>pt:<em>    <\/em>- npm run build<em>  arti<\/em>facts:<em>    pa<\/em>ths:<em>      <\/em>- dist\/<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4efb\u52a1\u540e\u9762\u8fd0\u884c\u7684\u4efb\u52a1\u4f1a\u81ea\u52a8\u6062\u590d\u8fd9\u4e2a\u5236\u54c1\uff0c\u610f\u5473\u7740\u4f60\u4e0d\u7528\u518d\u6267\u884c<code>npm run build<\/code>\u6765\u83b7\u53d6\u7f16\u8bd1\u540e\u7684<code>dist<\/code>\u6587\u4ef6\u4e86\uff0c \u5728\u5b89\u5353\uff0cios\u6253\u5305\u7684\u65f6\u5019\uff0c\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u6d41\u6c34\u7ebf\u6700\u7ec8\u8f93\u51fa\u7684\u5c31\u662f\u4e00\u4e2a\u53ef\u4e0b\u8f7d\uff0c\u53ef\u5b89\u88c5\u7684\u5e94\u7528\u3002 paths \u662f\u7528\u6765\u6307\u5b9a\u5c06\u90a3\u4e9b\u6587\u4ef6\uff0c\u76ee\u5f55\u653e\u5165\u5236\u54c1\u4e2d\uff0c \u4e5f\u53ef\u4ee5\u4f7f\u7528exclude\u5173\u952e\u8bcd\uff0c\u5c06\u90a3\u4e9b\u76ee\u5f55\uff0c\u6587\u4ef6\u6392\u9664\uff0c\u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 \u6b64\u5916\u8fd8\u6709\u4ee5\u4e0b\u51e0\u4e2a\u5c5e\u6027<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>paths \u6587\u4ef6\u8def\u5f84<\/li>\n\n\n\n<li>exclude \u6392\u9664\u7684\u6587\u4ef6<\/li>\n\n\n\n<li>name \u5236\u54c1\u540d\u79f0<\/li>\n\n\n\n<li>expose_as \u5728UI\u9875\u9762\u5bfc\u51fa\u7684\u540d\u79f0<\/li>\n\n\n\n<li>untracked \u5e03\u5c14\u7c7b\u578b\uff0c\u662f\u5426\u5c06git\u5ffd\u7565\u7684\u6587\u4ef6\u52a0\u5230\u5236\u54c1\u4e2d<\/li>\n\n\n\n<li>when on_success\uff1bon_failure\uff1balways \u4f55\u65f6\u4e0a\u4f20\u5236\u54c1<\/li>\n\n\n\n<li>expire_in \u8fc7\u671f\u65f6\u95f4\u9ed8\u8ba430\u5929<\/li>\n\n\n\n<li>reports \u6536\u96c6\u6d4b\u8bd5\u62a5\u544a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><em>build<\/em>:<em>  scri<\/em>pt:<em>    <\/em>- npm run build<em>  arti<\/em>facts:<em>    pa<\/em>ths:<em>      <\/em>- dist\/<em>    ex<\/em>clude:<em>      <\/em>- binaries\/**\/*.o<em>    ex<\/em>pose_as: 'artifact 1'<em>    na<\/em>me: \"$CI_COMMIT_REF_NAME\"<em>    un<\/em>tracked: false<em>    ex<\/em>pire_in: 2 hrs 20 min<em>    wh<\/em>en: on_failure<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/yehe.woa.com\/column\/support-plan\/article-edit\/15588369\">tags<\/a><\/p>\n\n\n\n<p>tags \u5173\u952e\u8bcd\u662f\u7528\u4e8e\u6307\u5b9aRunner,tags\u7684\u53d6\u503c\u8303\u56f4\u662f\u5728\u8be5\u9879\u76ee\u53ef\u89c1\u7684runner tags\u4e2d\uff0c\u53ef\u4ee5\u5728Setting =&gt;CI\/CD =&gt; Runner \u4e2d\u67e5\u770b\u7684\u5230\u3002 \u8981\u77e5\u9053\uff0c\u6539\u5c5e\u6027\u53ef\u4ee5\u8bbe\u7f6e\u5168\u5c40\uff0c\u4e0d\u8bbe\u7f6e\u5219\u9ed8\u8ba4\u4f7f\u7528\u516c\u6709Runner\u53bb\u6267\u884c\u6d41\u6c34\u7ebf\u3002\u6bcf\u4e2a\u4efb\u52a1\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2aRunner\uff0c\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a\u6807\u7b7e\uff0c\u4f46runner\u5374\u53ea\u80fd\u4e00\u4e2a\u3002\u4ee5\u4e00\u4e2a\u4e3a\u51c6\u3002tags\u662f\u5728\u6211\u4eec\u6ce8\u518cRunner\u662f\u914d\u7f6e\u7684,\u540e\u7eed\u4e5f\u53ef\u4ee5\u66f4\u6539\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>instal<\/em>l:<em>  tags<\/em>:<em>    <\/em>- hello-vue<em>    <\/em>- docker<em>  scri<\/em>pt:<em>    <\/em>- npm config set sass_binary_site https:\/\/npm.taobao.org\/mirrors\/node-sass\/<em>    <\/em>- npm install --registry=http:\/\/registry.npm.taobao.org<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/README.html#cache\">cache<\/a><\/p>\n\n\n\n<p>\u7f13\u5b58\u662f\u5c06\u5f53\u524d\u5de5\u4f5c\u73af\u5883\u76ee\u5f55\u4e2d\u7684\u4e00\u4e9b\u6587\u4ef6\uff0c\u4e00\u4e9b\u6587\u4ef6\u5939\u5b58\u50a8\u8d77\u6765\uff0c\u7528\u4e8e\u5728\u5404\u4e2a\u4efb\u52a1\u521d\u59cb\u5316\u7684\u65f6\u5019\u6062\u590d\u3002\u907f\u514d\u591a\u4e2a\u4e0b\u8f7d\u540c\u6837\u7684\u5305\uff0c\u80fd\u591f\u5927\u5927\u4f18\u5316\u6d41\u6c34\u7ebf\u6548\u7387\u3002\u5728\u524d\u7aef\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u628anode_modules\u7f13\u5b58\u8d77\u6765\uff0c\u8fd9\u6837\u4e00\u6761\u6d41\u6c34\u7ebf\u90fd\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u4e0b\u8f7d\u597d\u7684\u5305\u3002\u5728java\u9879\u76ee\u4e2d\u7ecf\u5e38\u628amaven\u4e0b\u8f7d\u7684\u5305\u7f13\u5b58\u8d77\u6765\u3002\u4ee5\u5907\u540e\u7528 cache\u4e0b\u7684\u53c2\u6570\u6709<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>paths \u5f53\u524d\u5de5\u4f5c\u73af\u5883\u4e0b\u7684\u76ee\u5f55<\/li>\n\n\n\n<li>key \u5b58\u50a8\u7684key\uff0ckey\u4e0d\u53d8\u4e0d\u4f1a\u91cd\u65b0\u751f\u6210\u7f13\u5b58\uff0c<\/li>\n\n\n\n<li>\ud83d\udd11prefix \u4f7f\u7528\u4e00\u4e9b\u6587\u4ef6\u5236\u4f5c\u6210\u6587\u4ef6hash\u503c\uff0c\u5f53\u505akey\u7684\u4e00\u90e8\u5206\uff0c<\/li>\n\n\n\n<li>untracked \u662f\u5426\u7f13\u5b58git\u5ffd\u7565\u7684\u6587\u4ef6<\/li>\n\n\n\n<li>when \u5b9a\u4e49\u4f55\u65f6\u5b58\u50a8\u7f13\u5b58 on_success\uff1bon_failure\uff1balways<\/li>\n\n\n\n<li>policy \u7f13\u5b58\u662f\u5426\u8981\u5728job\u5b8c\u6210\u540e\u91cd\u65b0\u4e0a\u4f20<\/li>\n<\/ul>\n\n\n\n<p>\u7f13\u5b58\u53ef\u4ee5\u8bbe\u7f6e\u6d41\u6c34\u7ebf\u5168\u5c40\uff0c\u4e5f\u53ef\u4ee5\u5728job\u4e2d\u8bbe\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>cache<\/em>:<em>  key<\/em>: hello-vue-cache<em>  path<\/em>s:<em>    <\/em>- node_modules<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><em>cache<\/em>:<em>  key<\/em>:<em>    fi<\/em>les:<em>      <\/em>- Gemfile.lock<em>      <\/em>- package.json<em>  path<\/em>s:<em>    <\/em>- vendor\/ruby<em>    <\/em>- node_modules<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/README.html#stage\">stage<\/a><\/p>\n\n\n\n<p>stage \u662f\u9636\u6bb5\u7684\u610f\u601d\uff0c\u7528\u4e8e\u5f52\u6863\u4e00\u90e8\u5206\u7684job\uff0c\u6309\u7167\u5b9a\u4e49\u7684stage\u987a\u5e8f\u6765\u6267\u884c\u3002 \u9ed8\u8ba4\u7684stage\u6709build\uff0ctest\uff0cdeploy\uff0c \u6b64\u5916\u8fd8\u6709\u4e24\u4e2a\u7279\u6b8a\u7684.pre \u548c .post job\u6267\u884c\u7684\u987a\u5e8f\u4e0d\u662f\u6309\u7167\u7f16\u5199\u7684\u987a\u5e8f\uff0c\u5927\u4f53\u4e0a\u662f\u6309\u7167stage\u5b9a\u4e49\u7684\u987a\u5e8f\u6765\u6267\u884c\u7684,\u6ce8\u610f\u662f\u5927\u4f53\uff0c\u4e5f\u6709\u4f8b\u5916\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>stages<\/em>:<em>  <\/em>- build<em>  <\/em>- test<em>  <\/em>- deploy<em>job 0<\/em>:<em>  stag<\/em>e: test<em>  scri<\/em>pt: echo 'tets'<em>job 1<\/em>:<em>  stag<\/em>e: build<em>  scri<\/em>pt: echo 'build'<\/code><\/pre>\n\n\n\n<p>\u7531\u4e8e<code>build<\/code>\u5728<code>test<\/code>\u4e4b\u524d\u6240\u6709\u4f1a\u6307\u5411<code>job1<\/code>\u8fd9\u4e2a\u4efb\u52a1\uff0c\u540e\u6307\u5411<code>job0<\/code>\u4efb\u52a1<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/README.html#when\">when<\/a><\/p>\n\n\n\n<p>when\u5173\u952e\u5b57\u662f\u5b9e\u73b0\u5728\u53d1\u751f\u6545\u969c\u6216\u5c3d\u7ba1\u53d1\u751f\u6545\u969c\u65f6\u4ecd\u80fd\u8fd0\u884c\u7684\u4f5c\u4e1a\u3002\u6bd4\u5982\u4f60\u8981\u5728\u4efb\u52a1\u5931\u8d25\u540e\u9700\u8981\u89e6\u53d1\u4e00\u4e2ajob\uff0c \u6216\u8005\u4f60\u9700\u8981\u624b\u52a8\u6267\u884c\u4efb\u52a1\uff0c\u6216\u8005\u5f53\u4f60\u4e00\u4e2a\u4efb\u52a1\u6267\u884c\u6210\u529f\u540e\uff0c\u6267\u884c\u53e6\u4e00\u4e2a\u4efb\u52a1.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>on_success \u6240\u6709\u4efb\u52a1\u6267\u884c\u6210\u529f\u540e<\/li>\n\n\n\n<li>on_failure \u5f53\u81f3\u5c11\u4e00\u4e2a\u4efb\u52a1\u5931\u8d25\u540e<\/li>\n\n\n\n<li>always \u6267\u884c\u4f5c\u4e1a\uff0c\u800c\u4e0d\u8003\u8651\u4f5c\u4e1a\u5728\u65e9\u671f\u9636\u6bb5\u7684\u72b6\u6001\u3002<\/li>\n\n\n\n<li>manual \u624b\u52a8\u6267\u884c\u4efb\u52a1<\/li>\n\n\n\n<li>delayed \u5ef6\u8fdf\u6267\u884c\u4efb\u52a1<\/li>\n\n\n\n<li>never \u5728<code>rules<\/code>\u4e2d\u4e0d\u6392\u9664\u6267\u884c\u7684\u4efb\u52a1 \u5728<code>workflow:rules<\/code>\u4e0d\u5141\u8bb8\u7684\u6d41\u6c34\u7ebf<\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/README.html#onlyexcept-basic\">only\/except<\/a><\/p>\n\n\n\n<p>only\/except \u662f\u89c4\u5b9a\u5f53\u524djob\u7684\u53ef\u89c1\u72b6\u6001\uff0c\u4e00\u4e2a\u9879\u76ee\u6709\u5f88\u591a\u5206\u652f\uff0ctag\uff0c\u6211\u4eec\u7684\u6d41\u6c34\u7ebf\uff0c\u4e3a\u4e86\u5bf9\u7279\u5b9a\u7684\u5206\u652f\uff0c\u7279\u5b9a\u7684tag\u6267\u884c\u4e0d\u540c\u7684job\uff0c\u8fd9\u91cc\u5c31\u8981\u4f7f\u7528only\u548cexcept \u5728\u4efb\u52a1\u4e0a\u52a0\u4e0a\u8fd9\u4e00\u6bb5\u4ee3\u7801\uff0c\u5c31\u8868\u660e\u5f53\u524d\u4efb\u52a1\u53ea\u6709\u5728master\u5206\u652f\u53ef\u4ee5\u8fd0\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>only<\/em>:<em>  <\/em>- master<\/code><\/pre>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u6839\u636e\u5f53\u524d\u7684\u4ee3\u7801\u53d8\u52a8\u662f\u5408\u5e76\uff0c\u8fd8\u662f\u63a8\u9001\uff0c\u8fd8\u662f\u4f7f\u7528API\u6765\u89e6\u53d1\u7684\u3002 \u5982\u679c\u4e00\u4e2a\u4efb\u52a1\u6ca1\u6709only\u5c5e\u6027\uff0c\u90a3\u9ed8\u8ba4\u5c31\u662f&nbsp;<code>only: ['branches', 'tags']<\/code>&nbsp;\u64cd\u4f5c\u5206\u652f\u6216\u8005tags\u90fd\u4f1a\u89e6\u53d1\u6d41\u6c34\u7ebf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528GitLab\u81ea\u5e26\u7684\u6d41\u6c34\u7ebf\uff0c\u5fc5\u987b\u8981\u5b9a\u4e49\u6d41\u6c34\u7ebf\u7684\u5185\u5bb9\uff0c\u800c\u5b9a\u4e49\u5185\u5bb9\u7684\u6587\u4ef6\u9ed8\u8ba4\u53eb\u505a.gitlab-ci.yml\uff0c\u4f7f\u7528yml\u7684\u8bed\u6cd5\u8fdb\u884c\u7f16\u5199\u3002 \u76ee\u524d\u4efb\u52a1\u5173\u952e\u8bcd\u670928\u4e2a\uff0c\u5168\u5c40\u7684\u5173\u952e\u8bcd\u670910\u4e2a\uff0c\u4e24\u8005\u91cd\u53e0\u7684\u6709\u5f88\u591a\u3002\u4eca\u5929\u6211\u7ed9\u5927\u5bb6\u5148\u8bb2\u89e3\u4e00\u4e0b\u5e38\u7528\u7684\u5173\u952e\u8bcd\uff0c\u638c\u63e1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"topic":[],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-21"],"_links":{"self":[{"href":"https:\/\/idc.birk.cn\/index.php?rest_route=\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.birk.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.birk.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.birk.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.birk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=48"}],"version-history":[{"count":3,"href":"https:\/\/idc.birk.cn\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/idc.birk.cn\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions\/53"}],"wp:attachment":[{"href":"https:\/\/idc.birk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.birk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.birk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=48"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/idc.birk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}