npm install --save generator-hubot npm install --save cron #npm install --save request #npm install --save hubot-scripts@latest mkdir hogebot cd hogebot yo hubot Bot adapter: rocketchat cat > ./scripts/hello.coffee << 'EOF' cronJob = require('cron').CronJob child_process = require('child_process') module.exports = (robot) -> robot.hear /hello/, (msg) -> msg.reply 'hi' cronjob = new cronJob('*/30 * * * * *', () => envelope = room: "general" command = "/home/hubot/script.sh" #robot.send envelope, "Command: #{command}" child_process.exec command, (error, stdout, stderr) -> robot.send envelope, error if error? robot.send envelope, stdout if stdout? && stdout.length > 0 robot.send envelope, stderr if stderr? && stderr.length > 0 ) cronjob.start() EOF cat > script.sh << 'EOF' #!/bin/bash curl http://jenkins:8080/ > /dev/null 2>&1 RET=$? if [ "${RET}" -ne 0 ]; then echo "jenkins is not alive. error:${RET}" fi exit ${RET} EOF