Panel |
---|
borderColor | green |
---|
title | Configuration |
---|
|
NodeServices config file | location | Description |
---|
config.json | app/config/config.json | config.json template is available. Update your environment specific values which are required to start NodeServices To enable approval flow for mattermost adapter set "APPROVAL_APP_URL=http://middleware-ip:port/endpoint" in config.json |
certificate.pem , key.pem | must be placed in root of the project which is parallel to app.js | Generate certificate and private key pem files |
admin.conf | must be placed in root of the project which is parallel to app.js | It can be found in kubernets master node instance. Path: /home/Ubuntu/admin.conf or /etc/kubernetes/admin.conf |
ubuntu.yaml | app/config/ubuntu.yaml which is parallel to config.json | Sample file already available. To create bots containers of kind “pod” |
Panel |
---|
|
Install dependencies with the following command:
Info |
---|
npm install will install the dependencies that are listed in package.json |
Run the app with the following command:
Panel |
---|
title | NodeServices Scripts |
---|
|
|
Scripts/Controller | Description |
---|
deploybot.js | Used to add/delete/stop the bot |
elasticApi.js | Connects to elasticsearch to fetch the metrics , hitmiss ratio and chatlogs of a bot |
hubotscripts.js | Construct shell scripts to start/stop/restart bot. Also, copying the workflow.json into container after edit. |
kubectlapi.js | Performs all container specific actions like create container, get logs from container, copying scripts into container, execute bot start/restart scripts in container,. using the Kubernetes. |
routes.js | mongodb query executions to add bot info as document, fetch document, update document and appending new values to a document | Individual bots can be set up manually by the process described below: - Clone our OnBot repository from github (git clone https://github.com/CognizantOneDevOps/OnBot.git)
- Copy the desired bot scripts from the scripts folder of the cloned repo
- Run this command: npm install -g yo generator-hubot
- Create a parent folder myhubot
- Run the following commands:
cd myhubot yo hubot - Copy the scripts from the cloned repository (first step) into myhubot/scripts folder
yo generator creates the package.json file under myhubot directory Download the workflow_botname.json attached with the respective bots below, then rename it as workflow.json and place into the myhubot directory - Run: npm install
- Now set the required environment variables (As mentioned below in Environment Variables for specific bots section and also refer section Environment variables common for all bots for additional common env variables)
- Slack: npm install hubot-slack Microsoft Teams: npm install hubot-botframewok
Finally, start the bot as a background process (logs will be redirected to hubot.log file): Slack: nohup ./bin/hubot -a slack > hubot.log & Microsoft Teams: nohup ./bin/hubot -a botframework > hubot.log & Info |
---|
Before starting the bot, Run npm install hubot-<adapter> to install specific node module for the adapter (chat application) you want to use. |
Note |
---|
At any time the bot running in background can be stopped by this command: ps aux | grep -ie <botname> | awk '{print $2}' | xargs kill -9 The <botname> can be fetched from the following line of the bin/hubot file: exec node_modules/.bin/hubot --name "botname" "$@" |
|
Panel |
---|
borderColor | green |
---|
title | Environment Variables for specific bots |
---|
|
Expand |
---|
|
Variable Name | Purpose |
---|
HUBOT_GIT_SOFTWARE | Specify which Software to be used for buildon (GitLab or GitHub) | HUBOT_GITLAB_IP | The GitLab server IP | GITLAB_SERVICE_TOKEN | Authentication token from gitlab | HUBOT_BUILDON_SERVICE | The buildon_host_address | POSTGRES_LINK | Postgres connection string (eg → jdbc:postgresql://<username>:<password>@<postgres_server_IP>:<port>/postgres) | BUILDON_TABLE_NAME | Table name from which buildon reports are taken by bot |
Info |
---|
title | Additional Information |
---|
| In addition to the default dependencies, the package.json of the bot should have the following dependencies: "hubot": "^2.19.0" "i": "^0.3.5" "monitor": "^0.6.10" "nedb": "^1.8.0" "npm": "^5.1.0" "request": "^2.81.0" "pg": "6.4.2" |
|
Expand |
---|
|
Variable name | Purpose |
---|
HUBOT_GITHUB_API | Github API link (https://api.github.com) | HUBOT_GITHUB_USER | Github username | HUBOT_GITHUB_TOKEN | Github oAuth token with appropriate permissions (Refer here to learn more about github oAuth tokens) | HUBOT_GITHUB_REPO | Default github repository name (optional) |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
HUBOT_GITLAB_API | Gitlab API URL (eg - http://<gitlab_host_ip>/api/v4) | HUBOT_GITLAB_USER | Gitlab user | HUBOT_GITLAB_TOKEN | Gitlab Personal access token with appropriate permissions (Click here to learn more about Gitlab personal access tokens) |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable Name | Purpose |
---|
HUBOT_GRAFANA_HOST | Grafana host url | HUBOT_GRAFANA_API_KEY | Grafana API key | NEO4J_USERNAME | Neo4j database username | NEO4J_PASSWORD | Neo4j database password | INSIGHT_URL | Insights host url | CHANNEL_ID | channel ID for slack/Hipchat and channel name for mattermost where grafana panel images will be uploaded | AUTH_TOKEN | Authentication token with upload permission |
Info |
---|
title | Additional Information |
---|
| installcurl.sh → Required to install curl dynamically if not installed already In addition to the default dependencies, the package.json of the bot should have the following dependencies: "date-now": "^1.0.1" "fs.notify": "0.0.4" "hubot": "^2.19.0" "hubot-grafana": "^1.6.0" "hubot-slack": "^4.4.0" "monitor": "^0.6.10" "neo4j": "^2.0.0-RC2" "neo4j-driver": "^1.5.0" "request": "^2.81.0" "unix-time": "^1.0.1" |
|
Expand |
---|
|
Variable name | Purpose |
---|
HUBOT_JENKINS_URL | Jenkins host URL | HUBOT_JENKINS_USER | Jenkins username | HUBOT_JENKINS_PASSWORD | Jenkins password | HUBOT_JENKINS_API_TOKEN | Jenkins API token | HUBOT_JENKINS_VERSION | Jenkins version (give upto 2 decimal only. eg - if version is 2.12.1, give 2.12) |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "hubot-jenkins": "^1.0.2" "hubot-slack": "^4.3.3" "hubot-yardmaster": "^1.0.30" "jenkins": "^0.20.0" "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
NEXUS_USER_ID | Nexus username | NEXUS_PASSWORD | Nexus password | NEXUS_URL | Nexus host URL |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration package.json of the bot should have the following dependencies: "cli-table": "^0.3.1" "fs.notify": "0.0.4" "hubot": "^2.19.0" "moment": "^2.20.1" "mongodb": "^2.2.33" "monitor": "^0.6.10" "nedb": "^1.8.0" "request": "^2.83.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
HUBOT_JIRA_URL | Jira host URL | HUBOT_JIRA_USER | Jira username | HUBOT_JIRA_PASSWORD | Jira password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
RUNDECK_URL | Rundeck host URL | RUNDECK_TOKEN | Rundeck API token | RUNDECK_USERNAME | Rundeck user name | RUNDECK_PASSWORD | Rundeck password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
SCALR_API_URL | Scalr host URL | SCALR_ACCESS_ID | Access ID of scalr | SCALR_ACCESS_KEY | Access key of scalr | SCALR_ENV_ID | Environment ID on which the bot should work | NODE_TLS_REJECT_UNAUTHORIZED | To skip ssl validation | SCALR_PROJECT_ID | Project ID on which the bot should work | SCALR_CLOUD_PLATFORM | Scalr cloud platform (eg → ec2) | SCALR_CLOUD_LOCATION | Cloud location of scalr (eg → us-west-2) | SCALR_NETWORK_ID | Network ID on which bot should work (vpc) | SCALR_SUBNET_ID | The subnet ID which is included in the above vpc | SCALR_SECURITY_GROUP_ID | Security group ID which operates on the above subnet |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
SONAR_URL | Sonar host URL | SONAR_USER_ID | Sonar user name | SONAR_PASSWORD | Sonar password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration package.json of the bot should have the following dependencies: "moment":"*", "mongodb":"^2.2.31", "fs.notify":"*", "xml2js":"*", "monitor": "^0.6.10", "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
UDEPLOY_URL | Udeploy host URL | UDEPLOY_USER_ID | Udeploy username | UDEPLOY_PASSWORD | Udeploy password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
URELEASE_URL | Urelease host URL | URELEASE_USER_ID | Urelease username | URELEASE_PASSWORD | Urelease password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
XLDEPLOY_URL | XLDeploy host URL | XLDEPLOY_USER_ID | XLDeploy username | XLDEPLOY_PASSWORD | XLDeploy password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
XLRELEASE_URL | XLRelease host URL | XLRELEASE_USERNAME | XLRelease username | XLRELEASE_PASSWORD | XLRelease password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
ARTIFACTORY_HOST | Artifactory host URL | ARTIFACTORY_USER | Artifactory username | ARTIFACTORY_PASSWORD | Artifactory password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
API | Rally API URL | USERNAME | Rally username | PASSWORD | Rally password | API_TOKEN | Rally API acess token |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration The package.json of the bot should have the following dependencies: "moment":"*" "mongodb":"^2.2.31" "fs.notify":"*" "xml2js":"*" "monitor":"*" "request":"2.81.0" |
|
Expand |
---|
|
Variable name | Purpose |
---|
HUBOT_TEAMCITY_URL | Teamcity host URL | HUBOT_TEAMCITY_USERNAME | Teamcity username | HUBOT_TEAMCITY_PWD | Teamcity password |
Info |
---|
title | Additional Information |
---|
| workflow.json → Required for approval flow configuration In addition to the default dependencies, the package.json of the bot should have the following dependencies: "fs.notify": "*" "moment": "*" "mongodb": "^3.1.0" "monitor": "*" "request": "2.81.0" "xml2js": "*" |
|
Panel |
---|
borderColor | #31B3EB |
---|
borderWidth | 2 |
---|
title | Environment variables common for all bots |
---|
| EXPRESS_PORT (Port number where the hubot will run) MY_POD_IP (Host address where bot is running) MONITOR_INTERVAL (Time Interval for monitoring bot) MONITOR_RETENSION (mapped to 1 (stores a jsonobj in elasticsearch which has all hubot metrics of a current second)) MONGO_DB_URL (mongodb database name for approval process of bot actions) MONGO_COLL (mongodb collection name for approval process of bot actions) MONGO_COUNTER (mongodb collection name for storing the number of next ticket to be generated) MONGO_TICKETIDGEN (stores the Id of the collection referred by MONGO_COUNTER) APPROVAL_APP_URL (middleware application endpoint which will handle approval flow in mattermost) MONGO_DB_NAME (The database name which has MONGO_COLL and MONGO_COUNTER in it) Slack: HUBOT_SLACK_TOKEN (API token for connecting with slack) Mattermost MATTERMOST_ENDPOINT (context of the endpoint where bot is running with mattermost adapter) MATTERMOST_INCOME_URL (Mattermost Incoming webhook) MATTERMOST_TOKEN (Mattermost outgoing token - to be configured with outgoing webhook) Microsoft Teams BOTBUILDER_APP_ID (App Id of your bot) BOTBUILDER_APP_PASSWORD (secret password for your bot) BOTBUILDER_ENDPOINT (Sets a custom HTTP endpoint for your bot to receive messages on (default is /api/messages). For Example: /master , /github , /jira , /jenkins , /sendtobot) CURRENT_CHANNEL (MS Teams current channel incoming webhook url. Reference: https://docs.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors) ADMIN_CHANNEL (MS Teams admin channel incoming webhook url for approval workflow. Reference: https://docs.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors) |
Panel |
---|
borderColor | #31B3EB |
---|
borderStyle | dashed |
---|
title | MongoDB Collections Required For Approval Flow |
---|
| To implement the approval flow with the bot, whichever collection name you put in MONGO_COUNTER variable(mentioned above) should be present inside the db set by MONGO_DB_NAME. For example- suppose you have MONGO_COUNTER=counters and MONGO_DB_NAME=hubot set in your environment. Then you should have a database called "hubot" inside your mongodb. This "hubot" should contain a collection named "counters" having this structure: { _id: "ticketIdGenerator",seq: 100} To create a collection like this, go to your mongo shell and execute below steps: - use hubot
- db.createCollection("counters")
- db.counters.insert({_id: "ticketIdGenerator",seq: 100})
Info |
---|
The MONGO_TICKETIDGEN should contain the Id of the collection referred by MONGO_COUNTER. Therefore, for the above example, MONGO_TICKETIDGEN=ticketIdGenerator. |
|
Info |
---|
title | Reload command setting |
---|
| Hubot has a built in command which allows any changes made in the coffeeScripts to take effect without restarting the bot. This is ideal for developers who want to customize the scripts according to their unique needs. To use this command, open the hubot-scripts.json file inside your bot folder(myhubot) and write the following: Code Block |
---|
| ["reload.coffee"] |
Save this and run your bot as usual. Thereafter if you make any changes in coffeeScripts, simply run the "reload all scripts" command. This will take the in latest changes without interrupting the running bot. |
|