diff --git a/README.md b/README.md index 28c9ab2..cfe3376 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,8 @@ To get the administrator password created use the command: ```bash docker exec jenkins_master_1 cat /var/jenkins_home/secrets/initialAdminPassword ``` + +Remove **all** images: +```bash +docker images -q | xargs docker rmi -f +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0c4c7be..c23861e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,12 +59,8 @@ services: container_name: jenkins restart: always user: root - environment: - - 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 + env_file: + - ./env/jenkins.env secrets: - jenkins_admin_username - jenkins_admin_password @@ -84,14 +80,8 @@ services: image: sonarqube container_name: sonarqube restart: always - environment: - - sonar.jdbc.username=sonar - - 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 + env_file: + - ./env/sonar.env networks: - janus-net - sonar-net @@ -104,7 +94,7 @@ services: image: postgres container_name: sonar-db 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_PASSWORD=sonar volumes: @@ -121,7 +111,7 @@ networks: sonar-net: driver: bridge # 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: file: ./jenkins/user jenkins_admin_password: diff --git a/env/jenkins.env b/env/jenkins.env new file mode 100644 index 0000000..70f36ec --- /dev/null +++ b/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 \ No newline at end of file diff --git a/env/sonar.env b/env/sonar.env new file mode 100644 index 0000000..8418aac --- /dev/null +++ b/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 \ No newline at end of file diff --git a/jenkins/Dockerfile b/jenkins/Dockerfile index 3bf388a..a65b60c 100644 --- a/jenkins/Dockerfile +++ b/jenkins/Dockerfile @@ -16,7 +16,7 @@ RUN curl -fsSL https://get.docker.com -o get-docker.sh | sh USER jenkins # Security configuration scripts -COPY configuration/* /var/jenkins_home/init.groovy.d/security.groovy +COPY configuration/* /var/jenkins_home/init.groovy.d/ # Automatically installs plugins COPY plugins.txt /usr/share/jenkins/ref/plugins.txt diff --git a/jenkins/configuration/github.groovy b/jenkins/configuration/github.groovy deleted file mode 100644 index f67a27f..0000000 --- a/jenkins/configuration/github.groovy +++ /dev/null @@ -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.") \ No newline at end of file