Reputation: 38763
I want to trigger jenkins after push,write my shell script like this:
result=`git push|grep up`
echo "result:$result"
if [[$result != "Everything up-to-date"]] then
curl http://192.168.2.200:8080/view/gradle/job/soa-report-consumer/build
fi
but the result is null,by the way the git have no post-push hook.What should I do to get result of git push
?
Upvotes: 1
Views: 693
Reputation: 1490
The result of git push
will go to stderr
.
Do it by redirecting stderr
to stdout
with git push 2>&1 | grep up
.
(By the way, you should improve your grep
- like grep "up-to-date"
, since it could match any string up
, not necessarily the result you want)
Upvotes: 4
Reputation: 82
Try this :
$ status=$(git push 2>&1)
$ echo $status
Everything up-to-date
Upvotes: 1