{"id":119,"date":"2023-12-29T22:44:26","date_gmt":"2023-12-30T03:44:26","guid":{"rendered":"https:\/\/coding101.xyz\/?p=119"},"modified":"2023-12-31T13:27:27","modified_gmt":"2023-12-31T18:27:27","slug":"gitlab-ci-cd-primer","status":"publish","type":"post","link":"https:\/\/coding101.xyz\/?p=119","title":{"rendered":"Gitlab CI\/CD Primer"},"content":{"rendered":"\n<!--more-->\n\n\n\n<p>GitLab has a CI\/CD defined in a file called <strong>.gitlab-ci.yml<\/strong> <\/p>\n\n\n\n<p>This is a sample for the file<\/p>\n\n\n\n<!-- HTML generated using hilite.me --><div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\"><pre style=\"margin: 0; line-height: 125%\">stages:\n  - build_stage\n  - deploy_stage\nbuild:\n  stage: build_stage\n  image: node\n  script:\n    - npm install\n  artifacts:\n    paths:\n      - node_modules\n      - package-lock.json\ndeploy:\n  stage: deploy_stage\n  image: node\n  script:\n    - echo &quot;first&quot;\n    - node whatever.js\n<\/pre><\/div>\n\n\n\n<p>A couple of things:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>There are a number of stages, they are executed in order<\/li>\n\n\n\n<li>Each job is defined with a stage. The default state &#8211; if missing &#8211; is called test and it is predefined<\/li>\n\n\n\n<li>The jobs within a stage you cannot control in which order are executed, that is the reason we use stages<\/li>\n\n\n\n<li>You can create your own runner &#8211; machine that runs builds<\/li>\n\n\n\n<li>image: defines the docker image that is running the show. Default is some ruby stuff, so you want to define a good image unless you can run it with ruby<\/li>\n\n\n\n<li>artifacts: usually the products of the build in a stage \/ job are deleted, however if you want to keep them for the next stage, then you publish them with artifacts<\/li>\n\n\n\n<li>There are variables as well; the variables can be referred with $variable_name. There are predefined variables as well, see the docs <a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/variables\/predefined_variables.html\">here<\/a>. There are hidden variables as well, you defined them in the GUI and then you use them in the script without them appearing in clear.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=119"}],"version-history":[{"count":2,"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts\/119\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}