-
-
Save AssekoudaSamtou/881c0fe84b4c7a3042306f7b5386dfba to your computer and use it in GitHub Desktop.
GitLab CI .gitlab-ci.yml example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build | |
- test | |
- deploy | |
variables: | |
# from https://storage.googleapis.com/kubernetes-release/release/stable.txt | |
K8S_STABLE_VERSION_URL: https://storage.googleapis.com/kubernetes-release/release/v1.10.4/bin/linux/amd64/kubectl | |
build: | |
stage: build | |
image: docker:latest | |
services: | |
- docker:dind | |
script: | |
- export DOCKER_VERSION=$(echo "$CI_BUILD_REF" | cut -c 1-6) | |
- cd src/ProjectName && docker build -t registry.gitlab.com/username/project-name/webapp:$DOCKER_VERSION . | |
- cd ../../ && docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com | |
- docker push registry.gitlab.com/username/project-name/webapp:$DOCKER_VERSION | |
test: | |
stage: test | |
script: # TODO: write a test script | |
- exit 0 | |
dependencies: | |
- build | |
deploy_dev: | |
stage: deploy | |
environment: | |
name: Dev | |
image: alpine | |
script: | |
- apk add --no-cache curl | |
- curl -LO $K8S_STABLE_VERSION_URL | |
- chmod +x ./kubectl | |
- mv ./kubectl /usr/local/bin/kubectl | |
- mkdir ~/.kube | |
- cp $KUBECONFIG ~/.kube/config | |
- cat ~/.kube/config | |
- kubectl cluster-info | |
# If no error, connection to the cluster from the pipeline script is OK | |
# TODO: write a deploy script | |
dependencies: | |
- test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment