Tuesday, December 9, 2014

LAUNCH JENKINS AGENT and DISCONNECT JENKINS AGENT using CURL post requests in LINUX / UNIX

WHY do we need this function?
This function helps when you have some changes made to .bashrc or .bash_profile and those changes need to be reloaded and taken into account by jenkins agent.



Bash Function to LAUNCH JENKINS AGENT and DISCONNECT JENKINS AGENT using CURL

function launch-jenkins-agent
{
        SERVERNAME="server00"
        #SERVERNAME="server01"
        echo "usage: launch-jenkins-agent "
        cat $1 | awk '{print "curl --form \"offlineMessage=Restarting_agent_after_P4_changes\" https://${SERVERNAME}/computer/"$1"/launchSlaveAgent "}' |sh -x
}


function disconnect-jenkins-agent
{
        SERVERNAME="server00"
        #SERVERNAME="server01"
        echo "usage: disconnect-jenkins-agent "
        cat $1 | awk '{print "curl --form \"offlineMessage=Restarting_agent_after_P4_changes\" https://${SERVERNAME}/computer/"$1"/launchSlaveAgent "}' |sh -x

}


FUNCTION USAGE:
# disconnect-jenkins-agent  /tmp/multiple-hostnames
# launch-jenkins-agent   /tmp/multiple-hostname



No comments: