add Git stuff
This commit is contained in:
2
jenkins/.env
Normal file
2
jenkins/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
JENKINS_HOME_PATH=/home/soenke/docker-data/jenkins/jenkins_sandbox_home
|
||||
JENKINS_AGENT_SSH_PUBLIC_KEY="<< leave empty for now >>"
|
||||
65
jenkins/README.md
Normal file
65
jenkins/README.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# Jenkins with Docker Compose
|
||||
|
||||
Jenkins docker compose file (and instructions) to configure your jenkins controller and agent.
|
||||
|
||||
## Configuring Jenkins
|
||||
|
||||
1. Create the **jenkins_home** folder in your local environment
|
||||
|
||||
```
|
||||
mkdir jenkins_sandbox_home
|
||||
```
|
||||
|
||||
2. Create a file named **.env** and add the following:
|
||||
|
||||
```yml
|
||||
JENKINS_HOME_PATH=/home/user/jenkins_sandbox_home # your local jenkins_home path.
|
||||
JENKINS_AGENT_SSH_PUBLIC_KEY=<< leave empty for now >>
|
||||
```
|
||||
|
||||
3. Run Jenkins controller:
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
4. Get the password to proceed installation:
|
||||
|
||||
```bash
|
||||
docker logs jenkins_sandbox | less
|
||||
```
|
||||
|
||||
5. Go to <http://localhost:8080/> and enter the password.
|
||||
|
||||
6. Select **Install Suggested Plugins**, create the **admin** user and password, and leave the Jenkins URL <http://localhost:8080/>.
|
||||
|
||||
## Configuring Jenkins Agent
|
||||
|
||||
1. Use ssh-keygen to create a new key pair:
|
||||
|
||||
```bash
|
||||
ssh-keygen -t rsa -f jenkins_key
|
||||
```
|
||||
|
||||
2. Go to Jenkins and click **Manage jenkins** > **Manage credentials**.
|
||||
|
||||
3. Under **Stores scoped to Jenkins**, click **Global credentials**, next click **Add credentials** and set the following options:
|
||||
|
||||
- Select **SSH Username with private key**.
|
||||
- Limit the scope to **System**.
|
||||
- Give the credential an **ID**.
|
||||
- Provide a **description**.
|
||||
- Enter a **username**.
|
||||
- Under Private Key check **Enter directly**.
|
||||
- Paste the content of private key in the text box.
|
||||
|
||||
4. Click **Ok** to save.
|
||||
|
||||
5. Paste the public key on the **JENKINS_AGENT_SSH_PUBLIC_KEY** variable, in the **.env** file.
|
||||
|
||||
6. Recreate the services:
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
```
|
||||
23
jenkins/docker-compose.yml
Normal file
23
jenkins/docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
# Jenkins Sandbox
|
||||
version: "3"
|
||||
services:
|
||||
jenkins:
|
||||
image: jenkins/jenkins:lts
|
||||
container_name: jenkins_sandbox
|
||||
privileged: true
|
||||
user: root
|
||||
ports:
|
||||
- 8040:8080
|
||||
- 50000:50000
|
||||
volumes:
|
||||
- ${JENKINS_HOME_PATH}:/var/jenkins_home
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
agent:
|
||||
image: jenkins/ssh-agent:jdk11
|
||||
container_name: jenkins_sandbox_agent
|
||||
privileged: true
|
||||
user: root
|
||||
expose:
|
||||
- 22
|
||||
environment:
|
||||
- JENKINS_AGENT_SSH_PUBKEY=${JENKINS_AGENT_SSH_PUBLIC_KEY}
|
||||
Reference in New Issue
Block a user