Initial Commit
All checks were successful
andreas-personal/good-old-jenkins/pipeline/head This commit looks good

This commit is contained in:
Andreas Fahrecker 2024-03-14 21:31:22 +01:00
commit 552ed8a7a5
8 changed files with 99 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea/
*.iml

11
Dockerfile Normal file
View File

@ -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"

60
Jenkinsfile vendored Normal file
View File

@ -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'
}
}
}
}
}

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
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.

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# good-old-jenkins

11
alpine/Dockerfile Normal file
View File

@ -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"

2
alpine/executors.groovy Normal file
View File

@ -0,0 +1,2 @@
import jenkins.model.*
Jenkins.instance.setNumExecutors(0)

2
executors.groovy Normal file
View File

@ -0,0 +1,2 @@
import jenkins.model.*
Jenkins.instance.setNumExecutors(0)