You could setup a job which runs periodically on jenkins master.

Solution 1 ssh

# prepare info file
INFO_FILE=plugins.update.info
# CleanUp
rm -f *
touch $INFO_FILE
# get current version of cli JAR
wget http://127.0.0.1:8080/jnlpJars/jenkins-cli.jar
# update plugins
java -jar jenkins-cli.jar -ssh -user automationuser -i 
~/.ssh/automationuser/id_rsa list-plugins | grep ')$' >> ./report_raw || 
true
# format report-file
cat ./report_raw | sed s/'  '/'\t'/g >> ./report
# prepare update list
UPDATE_LIST=$( java -jar jenkins-cli.jar -ssh -user username -i 
~/path/to/id_rsa list-plugins | grep ')$' | cut -f 1 -d ' ' | sed 
':a;N;$!ba;s/\n/ /g' );
# update and create report
echo $UPDATE_LIST
if [ ! -z "${UPDATE_LIST}" ]; then
    java -jar jenkins-cli.jar -ssh -user username -i ~/path/to/id_rsa 
install-plugin ${UPDATE_LIST};
    java -jar jenkins-cli.jar -ssh -user username -i ~/path/to/id_rsa 
safe-restart;
    echo '<h2>Jenkins Plug-ins Update Report</h2>' >> $INFO_FILE
    echo 'The following plug-in updates have been conducted:' >> $INFO_FILE
    echo '<table>' >> $INFO_FILE
    echo '<tr><th align='left' style='padding-right:20px'>Plug-in 
ID</th><th align='left' style='padding-right:20px'>Plug-in name</th><th 
align='left' style='padding-right:20px'>Old Version</th><th align='left' 
style='padding-right:20px'>New Version</th><tr>' >> $INFO_FILE
    awk 'BEGIN { FS = "[()\t]+" } ;{print "<tr><td  align='left' 
style='padding-right:20px'>"$1"</td><td  align='left' 
style='padding-right:20px'>"$2"</td><td align='left' 
style='padding-right:20px'>"$3"</td><td align='left' 
style='padding-right:20px'>"$4"</td></tr>"}' report >> $INFO_FILE
    echo '</table>' >> $INFO_FILE
else    
    echo '<h2>Jenkins Plug-ins Update Report</h2>' >> $INFO_FILE
    echo '<p><b>No updates</b> for installed plug-ins were available!</p>' 
>> $INFO_FILE
fi
Solution 2 token
# prepare info file
INFO_FILE=plugins.update.info
rm -f $INFO_FILE
# get current version of cli JAR
rm -f jenkins-cli.jar
wget http://127.0.0.1:8080/jnlpJars/jenkins-cli.jar
# update plugins
rm -f ./tmp
rm -f ./tmp2
java -jar jenkins-cli.jar -auth username:token -s http://127.0.0.1:8080/ 
list-plugins | grep ')$' >> ./tmp | cat ./tmp | sed s/'  '/'\t'/g >> ./tmp2
UPDATE_LIST=$( java -jar jenkins-cli.jar -auth username:token -s 
http://127.0.0.1:8080/ list-plugins | grep ')$' | cut -f 1 -d ' ' | sed 
':a;N;$!ba;s/\n/ /g' );
if [ ! -z "${UPDATE_LIST}" ]; then
    java -jar jenkins-cli.jar -auth username:token -s 
http://127.0.0.1:8080/ install-plugin ${UPDATE_LIST};
    java -jar jenkins-cli.jar -auth username:token -s 
http://127.0.0.1:8080/ safe-restart;
    echo '<h2>Jenkins Plug-ins Update Report</h2>' >> $INFO_FILE
    echo 'The following plug-in updates have been conducted:' >> $INFO_FILE
    echo '<table>' >> $INFO_FILE
    echo '<tr><th align=\"left\" style=\"padding-right:20px\">Plug-in 
ID</th><th align=\"left\" style=\"padding-right:20px\">Plug-in name</th><th 
align=\"left\" style=\"padding-right:20px\">Old Version</th><th 
align=\"left\" style=\"padding-right:20px\">New Version</th><tr>' >> 
$INFO_FILE
    awk 'BEGIN { FS = "[()\t]+" } ;{print "<tr><td  align=\"left\" 
style=\"padding-right:20px\">"$1"</td><td  align=\"left\" 
style=\"padding-right:20px\">"$2"</td><td align=\"left\" 
style=\"padding-right:20px\">"$3"</td><td align=\"left\" 
style=\"padding-right:20px\">"$4"</td></tr>"}' tmp2 >> $INFO_FILE
    echo '</table>' >> $INFO_FILE
else
    echo '<h2>Jenkins Plug-ins Update Report</h2>' >> $INFO_FILE
    echo '<p><b>No updates</b> for installed plug-ins were 
available!</p>'>> $INFO_FILE
fi



Am Mittwoch, 17. Oktober 2018 23:18:26 UTC+2 schrieb [email protected]:
>
> Hi,
>
> We are using open source Jenkins and have a bunch of plugins installed.  
> Is there a way to update all the plugins that are in the "Updates" section 
> in the Plugin Manager?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/91f2a236-5e5d-4451-b84a-b042a966724e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to