1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jenkins_ynh.git synced 2024-09-03 19:26:18 +02:00

Several fixes

This commit is contained in:
yalh76 2022-03-18 00:27:06 +01:00
parent 1f3f203c32
commit 64adde4f81
7 changed files with 68 additions and 29 deletions

43
conf/config_unsecured.xml Normal file
View file

@ -0,0 +1,43 @@
<?xml version='1.1' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>2.332.1</version>
<numExecutors>2</numExecutors>
<mode>NORMAL</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
<disableSignup>true</disableSignup>
<enableCaptcha>false</enableCaptcha>
</securityRealm>
<disableRememberMe>false</disableRememberMe>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>all</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<primaryView>all</primaryView>
<slaveAgentPort>-1</slaveAgentPort>
<enabledAgentProtocols>
<string>CLI2-connect</string>
</enabledAgentProtocols>
<label></label>
<crumbIssuer class="hudson.security.csrf.DefaultCrumbIssuer">
<excludeClientIPFromCrumb>false</excludeClientIPFromCrumb>
</crumbIssuer>
<nodeProperties/>
<globalNodeProperties/>
<nodeRenameMigrationNeeded>false</nodeRenameMigrationNeeded>
</hudson>

View file

@ -1,4 +1,4 @@
#!/bin/bash
ss#!/bin/bash
#=================================================
# GENERIC START
@ -34,7 +34,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
# STOP SYSTEMD SERVICE
#=================================================
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="systemd"
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -65,7 +65,7 @@ ynh_backup --src_path="/etc/default/$app"
# START SYSTEMD SERVICE
#=================================================
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd"
#=================================================
# END OF SCRIPT

View file

@ -71,7 +71,7 @@ fi
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# MODIFY URL IN NGINX CONF
@ -140,7 +140,7 @@ ynh_store_file_checksum --file="/etc/default/jenkins"
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="300"
ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path="systemd" --timeout="300"
#=================================================
# RELOAD NGINX

View file

@ -152,14 +152,15 @@ timeout=3600
echo "127.0.0.1 $domain #jenkins" | tee -a /etc/hosts
# Wait for Jenkins to be fully started
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout"
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="$timeout"
# Enable Jenkins CLI Protocol/2 for jenkins-cli
# That the only protocol that allow connection without an authenticated user...
ynh_replace_string --match_string="<slaveAgentPort>0</slaveAgentPort>" --replace_string="&\n<enabledAgentProtocols><string>CLI2-connect</string></enabledAgentProtocols>" --target_file=$final_path/config.xml
cp -f ../conf/config_unsecured.xml $final_path/config.xml
chown jenkins: $final_path/config.xml
# Wait for Jenkins to be fully started
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout"
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="$timeout"
ynh_script_progression --message="Installing plugins..."
@ -176,12 +177,6 @@ do
fi
done
# Remove the public access
ynh_permission_update --permission="main" --remove="visitors"
ynh_replace_string --match_string="<useSecurity>true</useSecurity>" --replace_string="<useSecurity>false</useSecurity>" --target_file=$final_path/config.xml
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout"
jenkins_cli="ynh_exec_warn_less java -jar $final_path/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}"
# Install plugins for http authentication and ldap.
@ -215,12 +210,14 @@ $jenkins_cli install-plugin ansicolor
$jenkins_cli install-plugin fstrigger
# Set global security with ldap
cp ../conf/config.xml $final_path/
cp -f ../conf/config.xml $final_path/
chown jenkins: $final_path/config.xml
# Clean hosts file
sed -i '/#jenkins/d' /etc/hosts
ynh_permission_update --permission="main" --remove="visitors"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
@ -237,7 +234,7 @@ ynh_store_file_checksum --file="$final_path/config.xml"
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Extendable continuous integration server"
#=================================================
# START SYSTEMD SERVICE
@ -245,7 +242,7 @@ yunohost service add $app --description="Extendable continuous integration serve
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout"
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="$timeout"
#=================================================
# SETUP SSOWAT

View file

@ -37,7 +37,7 @@ fi
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="systemd"
#=================================================
# REMOVE DEPENDENCIES
@ -74,9 +74,6 @@ ynh_script_progression --message="Removing various files..."
# Remove a directory securely
ynh_secure_remove --file="/etc/default/jenkins"
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -114,14 +114,14 @@ ynh_restore_file --origin_path=/etc/default/$app
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Extendable continuous integration server"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600"
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="3600"
#=================================================
# SEND A README FOR THE ADMIN

View file

@ -55,7 +55,7 @@ ynh_backup_if_checksum_is_different --file="$final_path/config.xml"
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path="systemd"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
@ -151,7 +151,7 @@ ynh_systemd_action --service_name=nginx --action=reload
ynh_script_progression --message="Restarting Jenkins..."
# Wait for Jenkins to be fully started
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600"
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="3600"
#=================================================
# UPGRADE JENKINS-CLI.JAR
@ -168,8 +168,10 @@ ynh_script_progression --message="Upgrading plugins..."
cp $final_path/config.xml $final_path/config.xml.bak
ynh_replace_string --match_string="<useSecurity>true</useSecurity>" --replace_string="<useSecurity>false</useSecurity>" --target_file=$final_path/config.xml
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600"
cp -f ../conf/config_unsecured.xml $final_path/config.xml
chown jenkins: $final_path/config.xml
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd" --timeout="3600"
jenkins_cli="ynh_exec_warn_less java -jar $final_path/jenkins-cli.jar -s http://127.0.0.1:${port}${path_url%/}"
UPDATE_LIST=$($jenkins_cli list-plugins | grep -oP '^(.*?) ')
@ -192,14 +194,14 @@ ynh_store_file_checksum --file="$final_path/config.xml"
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Extendable continuous integration server"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="restart" --line_match="Started" --log_path="systemd"
#=================================================
# SEND A README FOR THE ADMIN