How to get a list of installed Jenkins plugins with name and version pair

前端 未结 21 2253
误落风尘
误落风尘 2020-11-30 17:14

How can I get a list of installed Jenkins plugins?

I searched the Jenkins Remote Access API document, but it was not found. Should I use Jenkins\' CLI? Is there a d

21条回答
  •  醉话见心
    2020-11-30 17:22

    For Jenkins version 2.125 the following worked.

    NOTE: Replace sections that say USERNAME and APIKEY with a valid UserName and APIKey for that corresponding user. The API key for a user is available via Manage UsersSelect UserAPI Key option.

    You may have to extend the sleep if your Jenkins installation takes longer to start.

    The initiation yum update -y will upgrade the version as well if you installed Jenkins using yum as well.

    #JENKINS AUTO UPDATE SCRIPT link this script into a cron
    ##############
    !/bin/bash
    sudo yum update -y
    sleep 120
    UPDATE_LIST=$( sudo /usr/bin/java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -auth [USERNAME:APIKEY] -s http://localhost:8080/ list-plugins | grep -e ')$' | awk '{ print $1 }' );
    if [ ! -z "${UPDATE_LIST}" ]; then
        echo Updating Jenkins Plugins: ${UPDATE_LIST};
        sudo /usr/bin/java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -auth [USERNAME:APIKEY] -s http://localhost:8080/ install-plugin ${UPDATE_LIST};
        sudo /usr/bin/java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -auth [USERNAME:APIKEY] -s http://localhost:8080/ safe-restart;
    fi
    ##############
    

提交回复
热议问题