Last active
August 29, 2015 13:59
-
-
Save parnurzeal/10811308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
COMMAND=$1 | |
PARAM1=$2 | |
PARAM2=$3 | |
PARAM3=$4 | |
curl "http://dev-agspchef105z.dev.jp.local:8080/job/gspope-chef-repo/buildWithParameters?OBJECT=$COMMAND&PARAM1=$PARAM1&PARAM2=$PARAM2&PARAM3=$PARAM3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<File> | |
[alias] | |
commitpushbump = "!f(){ git commit -m \"$1 $2\" && git push origin master && curl -q 'http://192.168.50.3:8080/git/notifyCommit?url=ssh://[email protected]:7999/bddcheflab/theeraphol-chef-repo.git' && echo Please do \"git pull\" to get version bump update from Jenkins' }; f" | |
pbump = "!f(){ git push origin master && curl -q 'http://192.168.50.3:8080/git/notifyCommit?url=ssh://[email protected]:7999/bddcheflab/theeraphol-chef-repo.git' && echo Please do \"git pull\" to get version bump update from Jenkins' }; f" | |
<Commands> | |
git config alias.commitpushbump \"!f(){ git commit -m \"$1 $2\" && git push origin master && curl -q 'http://192.168.50.3:8080/git/notifyCommit?url=ssh://[email protected]:7999/bddcheflab/theeraphol-chef-repo.git' && echo Please do \"git pull\" to get version bump update from Jenkins' }; f" | |
git config alias.pbump \"!f(){ git push origin master && curl -q 'http://192.168.50.3:8080/git/notifyCommit?url=ssh://[email protected]:7999/bddcheflab/theeraphol-chef-repo.git' && echo Please do \"git pull\" to get version bump update from Jenkins' }; f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout master | |
COOKBOOK=`git log -1 --pretty=%s | awk '{print $1}'` | |
VERSION=`git log -1 --pretty=%s | awk '{print $2}'` | |
# In case, Jenkins commit merge before build | |
if [ "$COOKBOOK" == "Merge" ] ; then | |
COOKBOOK=`git log -2 --pretty=%s | tail -1 | awk '{print $1}'` | |
VERSION=`git log -2 --pretty=%s | tail -1 | awk '{print $2}'` | |
fi | |
echo "Receiving parameter: COOKBOOK=$COOKBOOK VERSION=$VERSION" | |
if [ $VERSION -eq "" ] ; then | |
echo "No specified version. Starting bump $COOKBOOK (patch version) ..." | |
knife spork bump git-cookbook | |
else | |
echo "Starting bump $COOKBOOK to $VERSION ..." | |
knife spork bump git-cookbook manual $VERSION | |
fi | |
knife spork upload git-cookbook | |
git add "cookbooks/$COOKBOOK/metadata.rb" | |
git commit -m "[Jenkins] Finished bumping $COOKBOOK to $VERSION" | |
git push origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout master | |
OBJECT=`git log -1 --pretty=%s | awk '{print $1}'` | |
PARAM1=`git log -1 --pretty=%s | awk '{print $2}'` | |
PARAM2=`git log -1 --pretty=%s | awk '{print $3}'` | |
PARAM3=`git log -1 --pretty=%s | awk '{print $4}'` | |
# In case, Jenkins commit merge before build | |
if [ "$OBJECT" == "Merge" ] ; then | |
OBJECT=`git log -2 --pretty=%s | tail -1 | awk '{print $1}'` | |
PARAM1=`git log -2 --pretty=%s | tail -1 | awk '{print $2}'` | |
PARAM2=`git log -2 --pretty=%s | tail -1 | awk '{print $3}'` | |
PARAM3=`git log -2 --pretty=%s | tail -1 | awk '{print $4}'` | |
fi | |
echo "Receiving parameter: OBJECT=$OBJECT PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3" | |
if [ "$OBJECT" == "cookbook" ] ; then | |
if [ "$PARAM2" == "" ] ; then | |
echo "No specified version. Starting bump $COOKBOOK (patch version) ..." | |
knife spork bump $PARAM1 | |
else | |
echo "Starting bump $PARAM1 to $PARAM2 ..." | |
knife spork bump $PARAM1 manual $PARAM2 | |
fi | |
knife spork upload $PARAM1 | |
git add "cookbooks/$PARAM1/metadata.rb" | |
git commit -m "[Jenkins] Finished bumping $PARAM1 to $PARAM2" | |
git push origin master | |
elif [ "$OBJECT" == "role" ] ; then | |
knife role from file $PARAM1 | |
echo "Uploaded role $PARAM1" | |
elif [ "$OBJECT" == "environment" ] ; then | |
knife environment from file $PARAM1 | |
MSG="Uploaded environment $PARAM1" | |
elif [ "$OBJECT" == "run_list" ] ; then | |
if [ "$PARAM1" == "add" ] || [ "$PARAM1" == "remove" ] || [ "$PARAM1" == "set" ] ; then | |
echo "$PARAM1 runlist $PARAM2 $PARAM3" | |
knife node run_list $PARAM1 $PARAM2 "$PARAM3" | |
MSG="knife node run_list $PARAM1 $PARAM2 $PARAM3" | |
fi | |
else | |
echo "No correct command" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<project> | |
<actions/> | |
<description></description> | |
<keepDependencies>false</keepDependencies> | |
<properties/> | |
<scm class="hudson.plugins.git.GitSCM" plugin="[email protected]"> | |
<configVersion>2</configVersion> | |
<userRemoteConfigs> | |
<hudson.plugins.git.UserRemoteConfig> | |
<url>ssh://[email protected]:7999/bddcheflab/theeraphol-chef-repo.git</url> | |
<credentialsId>80041a02-67b5-490c-8d10-1a9237b43ffd</credentialsId> | |
</hudson.plugins.git.UserRemoteConfig> | |
</userRemoteConfigs> | |
<branches> | |
<hudson.plugins.git.BranchSpec> | |
<name>*/master</name> | |
</hudson.plugins.git.BranchSpec> | |
</branches> | |
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations> | |
<submoduleCfg class="list"/> | |
<extensions> | |
<hudson.plugins.git.extensions.impl.WipeWorkspace/> | |
</extensions> | |
</scm> | |
<canRoam>true</canRoam> | |
<disabled>false</disabled> | |
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> | |
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> | |
<triggers> | |
<hudson.triggers.SCMTrigger> | |
<spec></spec> | |
<ignorePostCommitHooks>false</ignorePostCommitHooks> | |
</hudson.triggers.SCMTrigger> | |
</triggers> | |
<concurrentBuild>false</concurrentBuild> | |
<builders> | |
<hudson.tasks.Shell> | |
<command>git checkout master | |
OBJECT=`git log -1 --pretty=%s | awk '{print $1}'` | |
PARAM1=`git log -1 --pretty=%s | awk '{print $2}'` | |
PARAM2=`git log -1 --pretty=%s | awk '{print $3}'` | |
PARAM3=`git log -1 --pretty=%s | awk '{print $4}'` | |
# In case, Jenkins commit merge before build | |
if [ "$OBJECT" == "Merge" ] ; then | |
OBJECT=`git log -2 --pretty=%s | tail -1 | awk '{print $1}'` | |
PARAM1=`git log -2 --pretty=%s | tail -1 | awk '{print $2}'` | |
PARAM2=`git log -2 --pretty=%s | tail -1 | awk '{print $3}'` | |
PARAM3=`git log -2 --pretty=%s | tail -1 | awk '{print $4}'` | |
fi | |
echo "Receiving parameter: OBJECT=$OBJECT PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3" | |
if [ "$OBJECT" == "cookbook" ] ; then | |
if [ "$PARAM2" == "" ] ; then | |
echo "No specified version. Starting bump $COOKBOOK (patch version) ..." | |
knife spork bump $PARAM1 | |
else | |
echo "Starting bump $PARAM1 to $PARAM2 ..." | |
knife spork bump $PARAM1 manual $PARAM2 | |
fi | |
knife spork upload $PARAM1 | |
git add "cookbooks/$PARAM1/metadata.rb" | |
git commit -m "[Jenkins] Finished bumping $PARAM1 to $PARAM2" | |
git push origin master | |
elif [ "$OBJECT" == "role" ] ; then | |
knife role from file $PARAM1 | |
echo "Uploaded role $PARAM1" | |
elif [ "$OBJECT" == "environment" ] ; then | |
knife environment from file $PARAM1 | |
MSG="Uploaded environment $PARAM1" | |
elif [ "$OBJECT" == "run_list" ] ; then | |
if [ "$PARAM1" == "add" ] || [ "$PARAM1" == "remove" ] || [ "$PARAM1" == "set" ] ; then | |
echo "$PARAM1 runlist $PARAM2 $PARAM3" | |
knife node run_list $PARAM1 $PARAM2 "$PARAM3" | |
MSG="knife node run_list $PARAM1 $PARAM2 $PARAM3" | |
fi | |
fi | |
</command> | |
</hudson.tasks.Shell> | |
</builders> | |
<publishers/> | |
<buildWrappers> | |
<hudson.plugins.ansicolor.AnsiColorBuildWrapper plugin="[email protected]"> | |
<colorMapName>xterm</colorMapName> | |
</hudson.plugins.ansicolor.AnsiColorBuildWrapper> | |
</buildWrappers> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -l | |
# trigger by curl -i 'http://dev-gspachef105z.dev.jp.local:8080/job/gspope-chef-repo/buildWithParameters?OBJECT=cookbook&PARAM1=...&PARAM2=...&PARAM3=...' | |
git checkout master | |
echo "Receiving parameter: OBJECT=$OBJECT PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3" | |
if [ "$OBJECT" == "cookbook" ] ; then | |
if [ "$PARAM1" == "" ] ; then | |
echo "No specified cookbook." | |
exit 1 | |
fi | |
if [ "$PARAM2" == "" ] ; then | |
echo "No specified version. Starting bump $COOKBOOK (patch version) ..." | |
knife spork bump $PARAM1 | |
else | |
echo "Starting bump $PARAM1 to $PARAM2 ..." | |
knife spork bump $PARAM1 manual $PARAM2 | |
fi | |
knife spork upload $PARAM1 | |
git add "cookbooks/$PARAM1/metadata.rb" | |
git commit -m "[Jenkins] Finished bumping $PARAM1 to $PARAM2" | |
git push origin master | |
elif [ "$OBJECT" == "role" ] ; then | |
knife role from file $PARAM1 | |
echo "Uploaded role $PARAM1" | |
elif [ "$OBJECT" == "environment" ] ; then | |
knife environment from file $PARAM1 | |
MSG="Uploaded environment $PARAM1" | |
elif [ "$OBJECT" == "run_list" ] ; then | |
if [ "$PARAM1" == "add" ] || [ "$PARAM1" == "remove" ] || [ "$PARAM1" == "set" ] ; then | |
echo "$PARAM1 runlist $PARAM2 $PARAM3" | |
knife node run_list $PARAM1 $PARAM2 "$PARAM3" | |
MSG="knife node run_list $PARAM1 $PARAM2 $PARAM3" | |
fi | |
else | |
echo "No correct command" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout master | |
OBJECT=`git log -1 --pretty=%s | awk '{print $1}'` | |
PARAM1=`git log -1 --pretty=%s | awk '{print $2}'` | |
PARAM2=`git log -1 --pretty=%s | awk '{print $3}'` | |
PARAM3=`git log -1 --pretty=%s | awk '{print $4}'` | |
# In case, Jenkins commit merge before build | |
if [ "$OBJECT" == "Merge" ] ; then | |
OBJECT=`git log -2 --pretty=%s | tail -1 | awk '{print $1}'` | |
PARAM1=`git log -2 --pretty=%s | tail -1 | awk '{print $2}'` | |
PARAM2=`git log -2 --pretty=%s | tail -1 | awk '{print $3}'` | |
PARAM3=`git log -2 --pretty=%s | tail -1 | awk '{print $4}'` | |
fi | |
echo "Receiving parameter: OBJECT=$OBJECT PARAM1=$PARAM1 PARAM2=$PARAM2 PARAM3=$PARAM3" | |
if [ "$OBJECT" == "role" ] ; then | |
knife role from file $PARAM1 | |
echo "Uploaded role $PARAM1" | |
elif [ "$OBJECT" == "environment" ] ; then | |
knife environment from file $PARAM1 | |
MSG="Uploaded environment $PARAM1" | |
elif [ "$OBJECT" == "run_list" ] ; then | |
if [ "$PARAM1" == "add" ] || [ "$PARAM1" == "remove" ] || [ "$PARAM1" == "set" ] ; then | |
echo "$PARAM1 runlist $PARAM2 $PARAM3" | |
knife node run_list $PARAM1 $PARAM2 "$PARAM3" | |
MSG="knife node run_list $PARAM1 $PARAM2 $PARAM3" | |
fi | |
fi | |
#echo "`date +%Y%M%d%h%m`: $MSG" >> operations.log | |
#git add -Av | |
#git commit -m "$MSG" | |
#git push origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment