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

Install fonctionnelle

This commit is contained in:
Maniack Crudelis 2016-11-30 17:41:41 +01:00
parent 85082b9ac0
commit ee2c2a2cbc
5 changed files with 137 additions and 35 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.swp
*~
Notes

51
conf/config.xml Normal file
View file

@ -0,0 +1,51 @@
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>1.0</version>
<numExecutors>2</numExecutors>
<mode>NORMAL</mode>
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy">
<denyAnonymousReadAccess>false</denyAnonymousReadAccess>
</authorizationStrategy>
<securityRealm class="hudson.security.LDAPSecurityRealm" plugin="ldap@1.13">
<server>ldap://localhost:389/</server>
<rootDN>dc=yunohost,dc=org</rootDN>
<inhibitInferRootDN>false</inhibitInferRootDN>
<userSearchBase></userSearchBase>
<userSearch>uid={0}</userSearch>
<groupMembershipStrategy class="jenkins.security.plugins.ldap.FromGroupSearchLDAPGroupMembershipStrategy">
<filter></filter>
</groupMembershipStrategy>
<managerPasswordSecret></managerPasswordSecret>
<disableMailAddressResolver>false</disableMailAddressResolver>
<displayNameAttributeName>displayname</displayNameAttributeName>
<mailAddressAttributeName>mail</mailAddressAttributeName>
<userIdStrategy class="jenkins.model.IdStrategy$CaseInsensitive"/>
<groupIdStrategy class="jenkins.model.IdStrategy$CaseInsensitive"/>
</securityRealm>
<disableRememberMe>false</disableRememberMe>
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
<workspaceDir>${ITEM_ROOTDIR}/workspace</workspaceDir>
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
<markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
<jdks/>
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
<clouds/>
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner class="hudson" reference="../../.."/>
<name>Tous</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
</views>
<primaryView>Tous</primaryView>
<slaveAgentPort>0</slaveAgentPort>
<label></label>
<nodeProperties/>
<globalNodeProperties/>
</hudson>

View file

@ -1,27 +1,31 @@
location YNH_LOCATION {
proxy_pass http://127.0.0.1:YNH_PORT;
location __PATH__ {
proxy_pass http://127.0.0.1:__PORT__;
proxy_redirect http://127.0.0.1:__PORT__ https://__DOMAIN____PATH__;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-User $remote_user;
proxy_max_temp_file_size 0;
sendfile off;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_max_temp_file_size 0;
proxy_connect_timeout 4m;
proxy_send_timeout 4m;
proxy_read_timeout 4m;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
sendfile off;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -1,11 +1,16 @@
{
"name": "Jenkins",
"id": "jenkins",
"packaging_format": 1,
"requirements": {
"yunohost": ">= 2.4"
},
"description": {
"en": "Serveur d'intégration continue extensible",
"fr": "Extendable continuous integration server"
},
"developer": {
"license": "free",
"maintainer": {
"name": "Julien Malik",
"email": "julien.malik@paraiso.me"
},
@ -18,7 +23,8 @@
"en": "Choose a domain for Jenkins",
"fr": "Choisissez un domaine pour Jenkins"
},
"example": "domain.org"
"example": "domain.org",
"default": "sous.crudelis-test4.fr"
},
{
"name": "path",
@ -27,7 +33,7 @@
"fr": "Choisissez un path pour Jenkins"
},
"example": "/jenkins",
"default": "/jenkins"
"default": "/"
},
{
"name": "is_public",

View file

@ -5,6 +5,7 @@ domain=$1
path=$2
is_public=$3
port=$4
app=jenkins
sudo yunohost app checkport $port
if [[ ! $? -eq 0 ]]; then
@ -19,11 +20,8 @@ if [[ ! $? -eq 0 ]]; then
fi
echo "Install dependencies..."
wget -q -O - "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key" | sudo apt-key add -
sudo bash -c "cat > /etc/apt/sources.list.d/jenkins.list << EOF
deb http://pkg.jenkins-ci.org/debian binary/
EOF
"
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins -y
@ -31,17 +29,24 @@ sudo apt-get install jenkins -y
if [[ "$path" != "/" ]];
then
# $ means 'process only the last line'
sudo sed -i '$ s@--ajp13Port=$AJP_PORT@--ajp13Port=$AJP_PORT --prefix=$PREFIX@g' /etc/default/jenkins
sudo sed -i '$ s@--httpPort=$HTTP_PORT"@--httpPort=$HTTP_PORT" --prefix=$PREFIX@g' /etc/default/jenkins
fi
sudo sed -i "s/HTTP_PORT=.*/HTTP_PORT=$port/g" /etc/default/jenkins
sudo service jenkins restart
sudo sed -i "s/-Djava.awt.headless=true/& -Djenkins.install.runSetupWizard=false/g" /etc/default/jenkins
sudo service $app restart # Redémarre jenkins
tempfile="$(mktemp)"
tail -f -n1 /var/log/$app/$app.log > "$tempfile" & # Suit le démarrage dans le log
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
sudo yunohost service add jenkins -l /var/log/jenkins/jenkins.log
echo "Nginx configuration (sso disabled)..."
sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf
sed -i "s@YNH_PORT@$port@g" ../conf/nginx.conf
sed -i "s@__PATH__@$path@g" ../conf/nginx.conf
sed -i "s@__PORT__@$port@g" ../conf/nginx.conf
sed -i "s@__DOMAIN__@$domain@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/jenkins.conf
sudo yunohost app setting jenkins is_public -v $is_public
@ -50,8 +55,41 @@ then
sudo yunohost app setting jenkins unprotected_uris -v "/"
fi
# restart 2 times for debug
sudo service jenkins restart
sudo service nginx reload
sudo yunohost app ssowatconf
# Surveille le démarrage du service.
config_OK=0
for i in `seq 1 60`
do # La boucle attend le démarrage de jenkins Ou 60 secondes.
if grep -q "INFOS: Jenkins is fully up and running" "$tempfile" && [ "$config_OK" -eq 0 ]; then
# Si le log annonce une première fois le démarrage de jenkins. Fait sauter la sécurité de la première connexion de l'admin. Qui bloque curl et demande une identification inexistante une fois sur deux...
sudo wget -nv --no-check-certificate https://$domain$path/jnlpJars/jenkins-cli.jar -O /var/lib/jenkins/jenkins-cli.jar
for i in `seq 1 60`
do # La boucle attend la mise à jour des dépôts de plugins. Ou 20 secondes.
if test -e /var/lib/jenkins/updates/default.json; then
break;
else
echo -n "." >&2
sleep 1
fi
done
java -jar /var/lib/jenkins/jenkins-cli.jar -s https://$domain$path install-plugin reverse-proxy-auth-plugin
sudo cp ../conf/config.xml /var/lib/jenkins/
sudo chown jenkins: /var/lib/jenkins/config.xml
sudo service $app restart # Puis redémarre à nouveau le service.
cat /dev/null > "$tempfile" # Purge le log de suivi du démarrage.
config_OK=1
i=1;
fi
if grep -q "INFOS: Jenkins is fully up and running" "$tempfile" && [ "$config_OK" -eq 1 ]; then
break # Si le log annonce une deuxième fois le démarrage d'etherpad, sort de la boucle.
fi
echo -n "." >&2
sleep 1
done
kill -s 15 $PID_TAIL > /dev/null # Arrête l'exécution de tail.
sudo rm "$tempfile"