From 552ed8a7a54752540497134b09748bd87460b59c Mon Sep 17 00:00:00 2001 From: Andreas Fahrecker Date: Thu, 14 Mar 2024 21:31:22 +0100 Subject: [PATCH] Initial Commit --- .gitignore | 2 ++ Dockerfile | 11 ++++++++ Jenkinsfile | 60 +++++++++++++++++++++++++++++++++++++++++ LICENSE | 9 +++++++ README.md | 2 ++ alpine/Dockerfile | 11 ++++++++ alpine/executors.groovy | 2 ++ executors.groovy | 2 ++ 8 files changed, 99 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Jenkinsfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 alpine/Dockerfile create mode 100644 alpine/executors.groovy create mode 100644 executors.groovy diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1062418 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +*.iml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2b31fab --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM jenkins/jenkins:latest + +USER root +RUN groupadd -g 281 docker +RUN usermod -aG docker jenkins + +COPY --chown=jenkins:jenkins executors.groovy /usr/share/jenkins/ref/init.groovy.d/executors.groovy + +# Install jenkins plugins +USER jenkins +RUN jenkins-plugin-cli --plugins "blueocean docker-workflow" diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..50acd8a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,60 @@ +#!groovy + +pipeline { + agent none + + stages { + stage('Build/Push Docker Image') { + when { + beforeAgent true; + branch 'main' + } + agent { + label 'linux' + } + environment { + DOCKER_HUB_CREDENTIALS = credentials('docker-hub-fah16145') + } + stages { + stage('Login') { + steps { + sh 'docker login -u ${DOCKER_HUB_CREDENTIALS_USR} -p ${DOCKER_HUB_CREDENTIALS_PSW}' + } + } + stage('Default Image') { + stages { + stage('Build') { + steps { + sh 'docker build -t fah16145/good-old-jenkins:latest .' + } + } + stage('Push') { + steps { + sh 'docker push fah16145/good-old-jenkins:latest' + } + } + } + } + stage('Alpine Image') { + stages { + stage('Build') { + steps { + sh 'docker build -t fah16145/good-old-jenkins:alpine alpine/' + } + } + stage('Push') { + steps { + sh 'docker push fah16145/good-old-jenkins:alpine' + } + } + } + } + } + post { + always { + sh 'docker logout' + } + } + } + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9e05981 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# good-old-jenkins + diff --git a/alpine/Dockerfile b/alpine/Dockerfile new file mode 100644 index 0000000..952166c --- /dev/null +++ b/alpine/Dockerfile @@ -0,0 +1,11 @@ +FROM jenkins/jenkins:alpine + +USER root +RUN addgroup --gid 281 docker +RUN addgroup jenkins docker + +COPY --chown=jenkins:jenkins executors.groovy /usr/share/jenkins/ref/init.groovy.d/executors.groovy + +# Install jenkins plugins +USER jenkins +RUN jenkins-plugin-cli --plugins "blueocean docker-workflow" diff --git a/alpine/executors.groovy b/alpine/executors.groovy new file mode 100644 index 0000000..0f6f064 --- /dev/null +++ b/alpine/executors.groovy @@ -0,0 +1,2 @@ +import jenkins.model.* +Jenkins.instance.setNumExecutors(0) diff --git a/executors.groovy b/executors.groovy new file mode 100644 index 0000000..0f6f064 --- /dev/null +++ b/executors.groovy @@ -0,0 +1,2 @@ +import jenkins.model.* +Jenkins.instance.setNumExecutors(0)