Initial commit

This commit is contained in:
Home-Cluster
2023-01-11 21:34:02 +00:00
commit 3c72161a18
6 changed files with 135 additions and 0 deletions

47
template/Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,47 @@
#!groovy
pipeline {
agent {
kubernetes {
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
name: {{k3sApp}}-image-build
spec:
serviceAccountName: jenkins-admin
nodeSelector:
kubernetes.io/arch: {{k3sArch}}
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command: ["tail"]
args: ["-f", "/dev/null"]
volumeMounts:
- name: kaniko-secret
mountPath: /kaniko/.docker
restartPolicy: Never
volumes:
- name: kaniko-secret
secret:
secretName: dockercred
items:
- key: .dockerconfigjson
path: config.json
"""
}
}
stages {
stage('Docker Build and Push') {
steps {
container("kaniko") {
sh 'destinationRegistry=`sed -n \'s/^destinationRegistry=\(.*\)/\1/p\' < config.conf`'
sh 'imageName=`sed -n \'s/^imageName=\(.*\)/\1/p\' < config.conf`'
sh 'imageTag=`sed -n \'s/^imageTag=\(.*\)/\1/p\' < config.conf`'
sh '/kaniko/executor --dockerfile `pwd`/Dockerfile --context `pwd` --destination ${destinationRegistry}/${imageName}:${imageTag}'
}
}
}
}
}

27
template/setup.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
echo "Hello, lets get your project set up. Please follow the prompts attentively."
echo ""
read -p " K3S Build Pod Name: " k3sApp
read -p " Build Architecture: [amd64 | arm64] " k3sArch
echo ""
echo "Creating Folders"
echo " Creating cicd/"
mkdir cicd
echo ""
echo "Loading files"
echo " Loading cicd/Jenkinsfile"
cp template/Jenkinsfile cicd/Jenkinsfile
sed -ie "s|{{k3sApp}}|$k3sApp|g" cicd/Jenkinsfile
sed -ie "s|{{k3sArch}}|$k3sArch|g" cicd/Jenkinsfile
rm cicd/Jenkinsfilee
echo ""
echo "Removing template folder"
# rm -rf template
echo ""
echo "Thank you! Happy building..."