Added Mysql CT

This commit is contained in:
2021-09-18 00:10:15 +00:00
parent 23ff5d6408
commit 5bab220db2
22 changed files with 692 additions and 8 deletions

View File

@@ -0,0 +1,27 @@
<flow-definition plugin="workflow-job@WorkFlowJobVersion">
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@WorkFlowCPSVersion">
<scm class="hudson.plugins.git.GitSCM" plugin="git@GITVersion">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>GitRepo</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/main</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="empty-list"/>
<extensions/>
</scm>
<scriptPath>BuildJenkinsFile</scriptPath>
<lightweight>true</lightweight>
</definition>
<triggers/>
<disabled>false</disabled>
</flow-definition>

View File

@@ -0,0 +1,18 @@
<?xml version="1.1" encoding="UTF-8"?><com.cloudbees.hudson.plugins.folder.Folder plugin="cloudbees-folder@FoldersVersions">
<description/>
<properties/>
<folderViews class="com.cloudbees.hudson.plugins.folder.views.DefaultFolderViewHolder">
<views>
<hudson.model.AllView>
<owner class="com.cloudbees.hudson.plugins.folder.Folder" reference="../../../.."/>
<name>All</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<tabBar class="hudson.views.DefaultViewsTabBar"/>
</folderViews>
<healthMetrics/>
<icon class="com.cloudbees.hudson.plugins.folder.icons.StockFolderIcon"/>
</com.cloudbees.hudson.plugins.folder.Folder>

View File

@@ -0,0 +1,21 @@
<?xml version='1.1' encoding='UTF-8'?>
<slave>
<name>LXCBuilder1</name>
<description></description>
<remoteFS>/home/jenkins</remoteFS>
<numExecutors>3</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="ssh-slaves@SSHAgentVersion">
<host>LXCBuilderIP</host>
<port>22</port>
<credentialsId></credentialsId>
<launchTimeoutSeconds>60</launchTimeoutSeconds>
<maxNumRetries>10</maxNumRetries>
<retryWaitTime>15</retryWaitTime>
<sshHostKeyVerificationStrategy class="hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy"/>
<tcpNoDelay>true</tcpNoDelay>
</launcher>
<label>LXCBuilder</label>
<nodeProperties/>
</slave>

View File

@@ -0,0 +1,5 @@
<?xml version='1.1' encoding='UTF-8'?>
<io.jenkins.plugins.thememanager.ThemeManagerPageDecorator plugin="theme-manager@ThemeManagerVersion">
<theme class="io.jenkins.plugins.darktheme.DarkThemeManagerFactory" plugin="dark-theme@DarkThemeVersion"/>
<disableUserThemes>false</disableUserThemes>
</io.jenkins.plugins.thememanager.ThemeManagerPageDecorator>

View File

@@ -0,0 +1,4 @@
<?xml version='1.1' encoding='UTF-8'?>
<locale plugin="locale@LocaleVersion">
<systemLocale>en_US</systemLocale>
<ignoreAcceptLanguage>true</ignoreAcceptLanguage>

View File

@@ -0,0 +1,18 @@
<?xml version='1.1' encoding='UTF-8'?>
<org.jenkinsci.plugins.golang.GolangBuildWrapper_-DescriptorImpl plugin="golang@GoPluginVersion">
<installations>
<org.jenkinsci.plugins.golang.GolangInstallation>
<name>latest</name>
<home></home>
<properties>
<hudson.tools.InstallSourceProperty>
<installers>
<org.jenkinsci.plugins.golang.GolangInstaller>
<id>GoVersion</id>
</org.jenkinsci.plugins.golang.GolangInstaller>
</installers>
</hudson.tools.InstallSourceProperty>
</properties>
</org.jenkinsci.plugins.golang.GolangInstallation>
</installations>
</org.jenkinsci.plugins.golang.GolangBuildWrapper_-DescriptorImpl>

View File

@@ -0,0 +1,56 @@
#!/bin/bash
#UserSettings
ThisScriptConfigured=no
GitRepo=https://git.bprieshof.nl/brammp/HS-Testing.git
JenkinsUsername=<Username>
JenkinsPassword=<Password>
LXCBuilderIP=<ip.of.the.BuilderCT>
#StaticVars
AdminPassword=$(cat /var/lib/jenkins/secrets/initialAdminPassword)
JeninsPlugins="dark-theme ssh-slaves workflow-aggregator locale golang git dark-theme copyartifact ws-cleanup"
#Check if script is configured
if [ $ThisScriptConfigured = no ]; then
echo "Script is not configured"
exit
fi
#Download Jenkins-CLI tool
curl localhost:8080/jnlpJars/jenkins-cli.jar -o /opt/jenkins-cli.jar
#Install Plugins
java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword install-plugin $JeninsPlugins
echo "jenkins.model.Jenkins.instance.securityRealm.createAccount(\"$JenkinsUsername\", \"$JenkinsPassword\")" | java -jar /opt/jenkins-cli.jar -s "http://localhost:8080" -webSocket -auth admin:$AdminPassword groovy =
#Installed plugin versions
InstalledPlugins=$(java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword list-plugins)
#Update configuratiopn before putting them in place
sed -i -e 's/LocaleVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^locale ' | awk '{ print $NF}')'/g' /opt/Setup/Configs/locale.xml
sed -i -e 's/DarkThemeVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^dark-theme ' | awk '{ print $NF}')'/g' -e 's/ThemeManagerVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^theme-manager ' | awk '{ print $NF}')'/g' /opt/Setup/Configs/io.jenkins.plugins.thememanager.ThemeManagerPageDecorator.xml
sed -i -e 's/GoPluginVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^golang ' | awk '{ print $NF}')'/g' -e 's/GoVersion/'$(curl -s https://golang.org/VERSION?m=text |sed 's/go//g')'/g' /opt/Setup/Configs/org.jenkinsci.plugins.golang.GolangBuildWrapper.xml
mv -t /var/lib/jenkins /opt/Setup/Configs/locale.xml /opt/Setup/Configs/io.jenkins.plugins.thememanager.ThemeManagerPageDecorator.xml /opt/Setup/Configs/org.jenkinsci.plugins.golang.GolangBuildWrapper.xml
#Restart
java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword safe-shutdown
echo "Waiting 30 sec for jenkins to shutdown"
sleep 30
systemctl restart jenkins
echo "Waiting 1 min for Systemctl to restart jenkins"
sleep 60
#Add Jobs
cat /opt/Setup/Configs/FolderJob.xml | sed -e 's/FoldersVersions/'$(printf "%s" "${InstalledPlugins%x}" | grep '^cloudbees-folder ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder
cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#Other-Builds/DistroBuilder.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/DistroBuilder
cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#CT-Build/Debian.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/Debian-LXC
cat /opt/Setup/Configs/BuildJobTemplate.xml | sed -e 's#BuildJenkinsFile#CT-Build/Alpine.Jenkinsfile#g' -e 's#GitRepo#'$GitRepo'#g' -e 's/GITVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^git ' | awk '{ print $NF}')'/g' -e 's/WorkFlowCPSVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-cps ' | awk '{ print $NF}')'/g' -e 's/WorkFlowJobVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^workflow-job ' | awk '{ print $NF}')'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-job LXC-ImgBuilder/Alpine-LXC
#Add Node
cat /opt/Setup/Configs/LXCBuilder1.xml | sed -e 's/SSHAgentVersion/'$(printf "%s" "${InstalledPlugins%x}" | grep '^golang ' | awk '{ print $NF}')'/g' -e 's/LXCBuilderIP/'$LXCBuilderIP'/g' | java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword create-node LXCBuilder1
# BuildDistroBuilder (add -f to wait for job completion)
java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword build LXC-ImgBuilder/DistroBuilder -f
#Run both LXC builds, to fetch the jenkins file and set update the available parameters (The builds WILL fail)
java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword build LXC-ImgBuilder/Debian-LXC
java -jar /opt/jenkins-cli.jar -s http://localhost:8080/ -webSocket -auth admin:$AdminPassword build LXC-ImgBuilder/Alpine-LXC
echo "Debian-LXC and Alpine-LXC build will fail, this is expected behaviour"
echo "Next step is to login to the jenins instance, update the credentials for the Node and delete the admin user"