mirror of
https://github.com/YunoHost-Apps/jenkins_ynh.git
synced 2024-09-03 19:26:18 +02:00
133 lines
5.7 KiB
Bash
133 lines
5.7 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
jenkins_version=$(ynh_app_upstream_version)
|
|
ynh_app_setting_set --app="$app" --key="overwrite_nginx" --value="1"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
ynh_setup_source --source_id="jenkins-plugin-manager" --dest_dir="$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
#=================================================
|
|
# INSTALL JENKINS
|
|
#=================================================
|
|
ynh_script_progression --message="Installing Jenkins..."
|
|
|
|
# Download jenkins deb file and install it.
|
|
dpkg --install --force-confnew "$install_dir/jenkins.deb" || true
|
|
dpkg_install_failed=$(dpkg-query -f '${status} ${package}\n' -W | awk '$4 ~ /^jenkins.*/ && $3 != "installed" {print $4}' | wc -l)
|
|
|
|
if [[ $dpkg_install_failed -ge 1 ]]; then
|
|
ynh_print_warn --message="The service jenkins cannot be started for now."
|
|
fi
|
|
|
|
#=================================================
|
|
# SETUP APPLICATION
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up application on port $port..."
|
|
|
|
echo "$jenkins_version" >> "$install_dir/jenkins.install.InstallUtil.lastExecVersion"
|
|
echo "$jenkins_version" >> "$install_dir/jenkins.install.UpgradeWizard.state"
|
|
chown "$app:$app" "$install_dir/jenkins.install.InstallUtil.lastExecVersion"
|
|
chown "$app:$app" "$install_dir/jenkins.install.UpgradeWizard.state"
|
|
|
|
ynh_replace_string --target_file="/lib/systemd/system/jenkins.service" \
|
|
--match_string="Environment=\"JENKINS_PORT=8080\"" \
|
|
--replace_string="Environment=\"JENKINS_PORT=$port\"\nEnvironment=\"JENKINS_PREFIX=$path\""
|
|
systemctl daemon-reload --quiet
|
|
|
|
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
|
|
|
|
if [[ $dpkg_install_failed -ge 1 ]]; then
|
|
dpkg --configure -a
|
|
fi
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..."
|
|
|
|
ynh_add_config --template="config.xml" --destination="$install_dir/config.xml"
|
|
chown "$app:$app" "$install_dir/config.xml"
|
|
|
|
#=================================================
|
|
# INSTALL PLUGINS
|
|
#=================================================
|
|
ynh_script_progression --message="Installing plugins..."
|
|
|
|
jenkins_plugin_manager=(
|
|
ynh_exec_warn_less java -jar "$install_dir/jenkins-plugin-manager.jar" --war /usr/share/java/jenkins.war --plugin-download-directory="$install_dir/plugins"
|
|
)
|
|
|
|
# Install plugins for http authentication and ldap.
|
|
"${jenkins_plugin_manager[@]}" --plugins reverse-proxy-auth-plugin
|
|
|
|
# Install recommended plugins (those from Setup Wizard)
|
|
"${jenkins_plugin_manager[@]}" --plugins cloudbees-folder # Folders Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins antisamy-markup-formatter # OWASP Markup Formatter Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins pam-auth # PAM Authentication plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins mailer # Mailer Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins ldap # LDAP Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins matrix-auth # Matrix Authorization Strategy Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins build-timeout # Build timeout plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins credentials-binding # Credentials Binding Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins timestamper # Timestamper
|
|
"${jenkins_plugin_manager[@]}" --plugins ws-cleanup # Workspace Cleanup Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins ant # Ant Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins gradle # Gradle Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins workflow-aggregator # Pipeline
|
|
"${jenkins_plugin_manager[@]}" --plugins pipeline-stage-view # Pipeline: Stage View Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins git # Git plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins github-branch-source # GitHub Branch Source Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins subversion # Subversion Plug-in
|
|
"${jenkins_plugin_manager[@]}" --plugins email-ext # Email Extension Plugin
|
|
"${jenkins_plugin_manager[@]}" --plugins ssh-slaves # SSH Slaves plugin
|
|
|
|
# Install extra comfort plugins
|
|
# Handle terminal colours. Enhance the readability of the terminal.
|
|
"${jenkins_plugin_manager[@]}" --plugins ansicolor
|
|
# Monitoring of the local file system. Allow to monitor a directory and trig a job if a file has been modified.
|
|
"${jenkins_plugin_manager[@]}" --plugins fstrigger
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Service is provided by the deb package
|
|
yunohost service add "$app" --description="Jenkins Continuous Integration Server"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..."
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed"
|