项目作者: crunchy-devops

项目描述 :
CI/CD platform using Jenkins, docker, Sonar, Nexus, JMeter, Selenium, gitlab-ce, Ansible, AWX
高级语言: Dockerfile
项目地址: git://github.com/crunchy-devops/jenkins-pic.git
创建时间: 2020-05-10T05:38:28Z
项目社区:https://github.com/crunchy-devops/jenkins-pic

开源协议:MIT License

下载


Jenkins CI-CD SandBox

(Beware: for a production usage you must set up this project on a Paas such as kubernetes or Openshift).

This Github Repo contains all relevant files for setting up an entirely CI/CD sandbox.

Docker CI Tools

This sandbox is only available on Linux.

Pre-requisite

You need a server/VM Ubuntu 24.04, 16GB of RAM, 4 cores, and 60 GB of SSD.

How to proceed ?

First install Docker

Go to UBUNTU.md markdown file and follow the instructions.

Install portainer for managing containers

  1. docker volume create portainer_data
  2. docker run -d -p 32125:8000 -p 32126:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock \
  3. -v portainer_data:/data portainer/portainer-ce:2.27.0-alpine

Quickly (there is a timeout), log on https://:32126
Set a password and activate portainer , you should see one container

  1. git clone https://github.com/<your github_account>/jenkins-pic.git
  2. cd jenkins-pic

I am using bitnami/version, for persistence the jenkins home is mapped to a docker volume
Edit and analyse the docker-compose.yml file and see the usage of volumes, services and network.

Launch all containers

Hit the following commands for starting up all containers

  1. docker-compose build # build all containers
  2. docker-compose up -d # launch all containers
  3. docker ps

Jenkins container sanity tests

Go to portainer
Select the container jenkins-pic-jenkins-1
docker logs jenkins-pic-jenkins-1
Get the initial admin password
Open a console on it
type docker ps , you should see all containers running on your vm
type jmeter --version , you should see jmeter prompt characters
type docker-compose --version , you should see version v2.29.1

check_docker_jmeter

Troubleshooting Sonarqube container

On the vm for fixing the sonarqube container
Add sudo sysctl -w vm.max_map_count=262144
or
Type this line
echo vm.max_map_count=262144 | sudo tee -a /etc/sysctl.conf
the variable is inserted in /etc/sysctl.conf
and run
sudo sysctl -p
to reload configuration with this new value
go to portainer web site and restart the container jenkins-pic-sonar-1

In some version of bitnami jenkins

You have to use the initial admin password
that is available in container log
docker logs jenkins-pic-jenkins-1

Sometimes bitnami default credential are

Log in as user and password is password

If you lost your password, jenkins is secure so you must recreate the default user

Go to jenkins
Go to portainer and select jenkins-pic-jenkins-1
edit /bitnami/jenkins/home/config.xml
change the <useSecurity>true</useSecurity>
to

  1. In portainer **Restart** the container jenkins-pic_jenkins_1
  2. Open your Chrome Browser
  3. type the URL http://<your_vm_ip_address>:32500
  4. Go to People on the left menu , and delete the current people named **user**
  5. Go to Dashboard->Manage Jenkins, choose Security , see the image below
  6. ![Security](screenshots/security.png)
  7. Hit save and you go right away the user screen to fill in.
  8. Enter **admin** as user name
  9. password : 12345678
  10. confirm: 12345678
  11. name : john
  12. ## Get an API token and set timezone
  13. click on user in right hand side on a top of a screen
  14. Hit configure
  15. select API Token , Add new token , give jetbrains name
  16. and Hit generate
  17. copy this token in your notepad for later use.
  18. go to Defined time zone. Select Europe/Paris
  19. Press save
  20. ## Overview
  21. Here is an overview of all tools:
  22. - Github is the well-known website for archiving all your projects.
  23. - Jenkins contains build job and is triggered once projects in GitHub are updated.
  24. - As part of the CI build, Jenkins triggers a static code analysis and the results are stored in SonarQube.
  25. - The Maven build uses Nexus as a Proxy Repository for all 3rd party libs. The build artifacts are deployed to the Nexus Release Repository.
  26. - Jmeter contains all requirements for running load testing and check performance regression.
  27. - The Selenium Grid contains Docker containers running Chrome and Firefox and is used for UI tests.
  28. ## Access Tools
  29. ### With docker containers
  30. | *Tool* | *Link* | *Credentials* |
  31. | --------- |-------------------------------------------| ------------- |
  32. | Jenkins | http://<vm_ip default>:32500/ | to be defined |
  33. | SonarQube | http://<vm_ip default>:32520/ | admin/admin |
  34. | Nexus | http://<vm_ip default>:32510/nexus | admin/use a token and set your own password |
  35. | Selenium Grid | http://<vm_ip default>:30044/grid/console | no login required |
  36. | Jmeter | no required | no login required |
  37. | Portainer | **https**://<vm_ip default>:32126 | enter a password at first log in |
  38. | Petclinic | http://<vm_ip default>:30190/petclinic | no login required |
  39. ## See more MarkDown files with instructions
  40. * FIRST_JOB.md
  41. * JETBRAINS.md
  42. * DEPLOYMENT.md
  43. * NEXUS_DOCKER_REGISTRY.md
  44. * JMETER.md
  45. * GITLAB.md
  46. * SELENIUM.md
  47. * PIPELINE_GUI.md
  48. * AWX.md
  49. * PIPELINE_SCRIPT.md
  50. ## Tips - some maintenance commands
  51. ### clean up all

docker system prune —all —volumes
docker rm -f $(docker ps -aq)
docker rmi -f $(docker images -aq)
docker volume rm $(docker volume ls -q)

=== remove docker daemon =======
sudo systemctl stop docker
sudo apt-get purge docker-ce -y
sudo apt-get autoremove —purge docker-ce -y
sudo groupdel docker
sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker

=== example of Docker dind ===
docker run -d —name test-dind —privileged -p 31999:2376 docker:dind
```