Infrastructure:
Ubuntu 1 | Ubuntu 2 |
---|---|
IP: 192.168.1.200/24 | IP: 192.168.1.201/24 |
docker | |
docker-compose | |
ansible |
Note: Both machines run as root user. All machines can ssh access by root without password to another.
git clone https://github.com/karrung/cicd-lab.git
cd cicd-lab
chmod +x ubuntu1-1-init.sh
./ubuntu1-1-init.sh
docker build -t myjenkins jenkins-docker
-
docker-compose up -d
-
- Open Jenkins http://192.168.1.200:8080
- Initial setup,
- Install suggested plugins
- Setup admin account
- Start using jenkins
- Open http://192.168.1.200:8080/pluginManager/available
- Install "GitLab Plugin" and "Gitlab Hook Plugin" restart Jenkins
- Open Jenkins http://192.168.1.200:8080
-
- Open Gitlab http://192.168.1.200:10080
- Create new password for root user.
- Signin with root user.
- New project:
- Project name: ckan
- Import project from: Repo by URL https://github.com/karrung/ckan.git
- Visibility Level: Internal
- In ckan project:
- Webhooks (http://192.168.1.200:10080/root/ckan/hooks):
- URL: http://192.168.1.200:8080/project/ckan
- Trigger: Push events
- Webhooks (http://192.168.1.200:10080/root/ckan/hooks):
- Open Gitlab http://192.168.1.200:10080
-
ansible-playbook -i ansible/host.txt ansible/prepare_docker.yaml
-
- Make sure jenkins container can ssh access to Ubuntun 2 192.168.1.201
- Enter an item name: ckan
- Select Pipeline
- Job ckan configure:
- Build Triggers: Build when a change is pushed to GitLab. GitLab CI Service URL: http://192.168.1.200:8080/project/ckan
- Pipeline:
- Definition: Pipeline script from SCM
- SCM: Git
- Repository URL: http://192.168.1.200:10080/root/ckan.git
- Credentials: From your gitlab account
- SCM: Git
- Definition: Pipeline script from SCM
modify ckan/templates/home/snippets/promoted.html
<h1>Test build by Jenkins 99</h1>
Push code to Gitlab , after jenkins build success open http://192.168.1.201