Browse Source

General improvements

master
Apostolos Fanakis 5 years ago
parent
commit
7831ac2023
  1. 5
      README.md
  2. 22
      docker-compose.yml
  3. 7
      env/jenkins.env
  4. 7
      env/sonar.env
  5. 2
      jenkins/Dockerfile
  6. 37
      jenkins/configuration/github.groovy

5
README.md

@ -10,3 +10,8 @@ To get the administrator password created use the command:
```bash ```bash
docker exec jenkins_master_1 cat /var/jenkins_home/secrets/initialAdminPassword docker exec jenkins_master_1 cat /var/jenkins_home/secrets/initialAdminPassword
``` ```
Remove **all** images:
```bash
docker images -q | xargs docker rmi -f
```

22
docker-compose.yml

@ -59,12 +59,8 @@ services:
container_name: jenkins container_name: jenkins
restart: always restart: always
user: root user: root
environment: env_file:
- VIRTUAL_HOST=jenkins.mthmmy.tk - ./env/jenkins.env
- VIRTUAL_PORT=8080
- LETSENCRYPT_HOST=jenkins.mthmmy.tk
- LETSENCRYPT_EMAIL=apotwohd@gmail.com
- SONARQUBE_HOST=127.0.0.1:9000
secrets: secrets:
- jenkins_admin_username - jenkins_admin_username
- jenkins_admin_password - jenkins_admin_password
@ -84,14 +80,8 @@ services:
image: sonarqube image: sonarqube
container_name: sonarqube container_name: sonarqube
restart: always restart: always
environment: env_file:
- sonar.jdbc.username=sonar - ./env/sonar.env
- sonar.jdbc.password=sonar
- sonar.jdbc.url=jdbc:postgresql://sonar-db:5432/sonar
- VIRTUAL_HOST=sonar.mthmmy.tk
- VIRTUAL_PORT=9000
- LETSENCRYPT_HOST=sonar.mthmmy.tk
- LETSENCRYPT_EMAIL=apotwohd@gmail.com
networks: networks:
- janus-net - janus-net
- sonar-net - sonar-net
@ -104,7 +94,7 @@ services:
image: postgres image: postgres
container_name: sonar-db container_name: sonar-db
restart: always restart: always
environment: # TODO: figure out another way to pass the username and password environment: # TODO: figure out another way to pass the username and password?
- POSTGRES_USER=sonar - POSTGRES_USER=sonar
- POSTGRES_PASSWORD=sonar - POSTGRES_PASSWORD=sonar
volumes: volumes:
@ -121,7 +111,7 @@ networks:
sonar-net: sonar-net:
driver: bridge driver: bridge
# Secrets in use # Secrets in use
secrets: # TODO: figure out a better way to do this secrets: # TODO: figure out a better way to do this?
jenkins_admin_username: jenkins_admin_username:
file: ./jenkins/user file: ./jenkins/user
jenkins_admin_password: jenkins_admin_password:

7
env/jenkins.env

@ -0,0 +1,7 @@
VIRTUAL_HOST=jenkins.mthmmy.tk
VIRTUAL_PORT=8080
LETSENCRYPT_HOST=jenkins.mthmmy.tk
LETSENCRYPT_EMAIL=apotwohd@gmail.com
SONARQUBE_HOST=127.0.0.1:9000
JENKINS_URL=https://jenkins.mthmmy.tk/
GITHUB_TOKEN=testssss

7
env/sonar.env

@ -0,0 +1,7 @@
VIRTUAL_HOST=sonar.mthmmy.tk
VIRTUAL_PORT=9000
LETSENCRYPT_HOST=sonar.mthmmy.tk
LETSENCRYPT_EMAIL=apotwohd@gmail.com
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://sonar-db:5432/sonar

2
jenkins/Dockerfile

@ -16,7 +16,7 @@ RUN curl -fsSL https://get.docker.com -o get-docker.sh | sh
USER jenkins USER jenkins
# Security configuration scripts # Security configuration scripts
COPY configuration/* /var/jenkins_home/init.groovy.d/security.groovy COPY configuration/* /var/jenkins_home/init.groovy.d/
# Automatically installs plugins # Automatically installs plugins
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt COPY plugins.txt /usr/share/jenkins/ref/plugins.txt

37
jenkins/configuration/github.groovy

@ -1,37 +0,0 @@
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import org.jenkinsci.plugins.plaincredentials.*
import org.jenkinsci.plugins.plaincredentials.impl.*
import hudson.util.Secret
import hudson.plugins.sshslaves.*
import org.apache.commons.fileupload.*
import org.apache.commons.fileupload.disk.*
import java.nio.file.Files
def env = System.getenv()
GITHUB_TOKEN = env['GITHUB_TOKEN']
domain = Domain.global()
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
println("== multibranch-github-pipeline.groovy => Starting.")
if ( GITHUB_TOKEN ) {
println("== multibranch-github-pipeline.groovy => Adding token.")
secretText = new StringCredentialsImpl(
CredentialsScope.GLOBAL,
"github-token",
"This is the token used for Github source branch plugin",
Secret.fromString(GITHUB_TOKEN)
)
store.addCredentials(domain, secretText)
println("== multibranch-github-pipeline.groovy => token added.")
}
println("== multibranch-github-pipeline.groovy => Done.")
Loading…
Cancel
Save