bayu nugraha
2 min readAug 9, 2019

Simple Gitlab Pipeline and How to Clone a Repository into Docker.

First step Click project, give your project name, chose private or public, in this case, I chose private.
Go to tab Settings > CI/CD > Variable, input like the picture below:

Variable

In this case, I have a username and password from Digital Ocean,
example: bro@12.345.67.8 and password 123456
F
rom the above picture, the first variable we input the password is 123456, the second variable we input server is 12.345.67.8, and the third variable we input username is bro.
Hide values and Save variables.

The second step is Go to Settings > Repository > Deploy Token
give it a name, give an expired day for your token checklist read_repository and click create deploy token, then will display username and password, save that username and password for clone repository to our docker container.
For more details go to this link https://docs.gitlab.com/ee/user/project/deploy_tokens/

The third step we are going to ssh into the server that we get from Digital Ocean. Create a directory in the server mkdir bro and create dockerfile with sudo nano Dockerfile like the image below:

Maintainer is your email and git clone is gitlab deploy token that we setting before. Save the file.
Run docker build -t bro . Don’t forget to write (.) After -t.
After that run this docker run -i -t -d —name bro bro
And check the docker ps -a will display the number container.
Come into the container with docker exec -it (container number) /bin/bash
In the container, we can find our gitlab repository that we created before.
This my gitlab repository, the name is first on the image below:

The fourth step we are going to Project > CI/CD configuration in your gitlab and create our first .gitlab-ci.yml scripts like this:
image: kroniak/ssh-client

stages:
— compile

before_script:
— apk update
— apk add sshpass -y

compile_master:
stage: compile
script:
— sshpass -p “$password” ssh -o StrictHostKeyChecking=no $username@$server “bash deploy-bro.sh
only:
— master

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

bayu nugraha
bayu nugraha

Written by bayu nugraha

Linux Administrator, Network Administrator, Cloud Engineer, DevOps Enthusiast, Docker, Jenkins, Git, Gitlab, Kubernetes, Ansible.

No responses yet

Write a response