GitLab CI/CD hello world examples
These are my notes for creating "hello world" and "docker hello world" GitLab CI/CD pipelines.
GitLab CI/CD hello world (gitlab repo) ¶
create git repo, push it to gitlab, and set origin. Replace
saltycrane
with your username.mkdir gitlab-ci-cd-hello-world cd gitlab-ci-cd-hello-world git init touch .gitignore git add . git commit -m 'first commit' git push --set-upstream [email protected]:saltycrane/gitlab-ci-cd-hello-world.git --all git remote add origin [email protected]:saltycrane/gitlab-ci-cd-hello-world.git
add a
.gitlab-ci.yml
filebuild-hello: script: - echo "hello world"
commit and push
git add . git commit -m 'add ci/cd config' git push origin
see the pipeline run (replace
saltycrane
with your username): https://gitlab.com/saltycrane/gitlab-ci-cd-hello-world/-/pipelines
GitLab CI/CD Docker hello world (gitlab repo) ¶
create git repo, push it to gitlab, and set origin. Replace
saltycrane
with your username.mkdir gitlab-ci-cd-docker-hello-world cd gitlab-ci-cd-docker-hello-world git init touch .gitignore git add . git commit -m 'first commit' git push --set-upstream [email protected]:saltycrane/gitlab-ci-cd-docker-hello-world.git --all git remote add origin [email protected]:saltycrane/gitlab-ci-cd-docker-hello-world.git
add a
Dockerfile
fileFROM alpine RUN echo "hello"
add a
.gitlab-ci.yml
filevariables: DOCKER_TLS_CERTDIR: "/certs" build-docker: image: docker:latest services: - docker:dind script: - docker build -t hello .
commit and push
git add . git commit -m 'add Dockerfile and ci/cd config' git push origin
see the pipeline run (replace
saltycrane
with your username): https://gitlab.com/saltycrane/gitlab-ci-cd-docker-hello-world/-/pipelines