Jenkins pipeline steps for integration with Hubot.
APACHE-2.0 License
= Hubot Pipeline Steps :toc: macro :note-caption: ℹ️ :tip-caption: 💡
image:images/JenkinsPlusHubot.png[Jenkins,300]
link:https://ci.jenkins.io/job/Plugins/job/hubot-steps-plugin/job/master/[image:https://ci.jenkins.io/job/Plugins/job/hubot-steps-plugin/job/master/badge/icon[Build]] image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License] link:https://plugins.jenkins.io/hubot-steps[image:https://img.shields.io/badge/Hubot%20Plugin-WIKI-blue.svg[Wiki]] image:https://badges.gitter.im/jenkinsci/hubot-steps-plugin.svg[link="https://gitter.im/jenkinsci/hubot-steps-plugin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"]
Jenkins Pipeline Steps for integration with the https://hubot.github.com/[Hubot Chat Bot] and with human approval.
''' toc::[]
== Configuration === Hubot Site
optional
, default to false. Default at folder level or Global level, when there are multiple default sites at the same level (Global or at a certain folder level), randomly picked.required
, site name.required
, hubot url, including port number, Ex: https://localhost:9999/
.optional
, room name, which can include #, depends on the chat service. Is optional when using folder name as room option.optional
, by default is false
, use folder name as room name.optional
, only applicable for folder name as room option enabled. Ex: For personal organization folder @ required to send direct messages.optional
, default true
.optional
- List of build notifications.optional
, list of rooms, comma separated, when it is different from actual room name above.optional
, list of tokens, comma separated, refer to https://wiki.jenkins.io/display/JENKINS/Token+Macro+Plugin[Token Macro plugin] for more info. Ex: 'BUILD_DURATION, BUILD_URL'
. NOTE: no ${}
around token name.=== Global Config
image::images/globalSite.png[Global Site,900]
=== Folder Config
image::images/folderSite.png[Folder Site,900]
=== Job Config
false
.optional
, given there is a default site at folder(or one of the parent folders) level/ global level.image::images/jobConfig.png[Job Config,900]
== Build Notifications
Supports sending notifications for the following build statuses.
image::images/buildNotifications.png[Build Notifications,900]
== Pipeline Steps
The following Jenkins pipeline steps are available.
=== hubotSend
Sends a given message to site/room.
required
, actual message to send.optional
, text which can be used in script to differentiate. Ex: INFO, WARN, ERROR or SUCCESS - So that in Slack it can be used to decide card colors.optional
, list of tokens, comma separated, Refer to https://wiki.jenkins.io/display/JENKINS/Token+Macro+Plugin[Token Macro plugin] for more information.optional
, extra data like attachments in case of slack, Any kind of Map, given it is Serializable.optional
, hubot site name either it is from Folder Level or Global Level, Only used when url is not present. Optional, it will fallback to first default site that it found while searching from immediate folder to Global site configurations.optional
, if it is provided as global environment variable HUBOT_URL or provided by withEnv
step, this should always end with /
, environment variable takes the lower precedence.optional
, if it is provided as global environment variable HUBOT_DEFAULT_ROOM or provided by withEnv
step, and room doesn't require #
, it is added in the code, environment variable takes the lower precedence.optional
and by default it is true
, if any error it won't abort the job, it can also be provided as global environment variable HUBOT_FAIL_ON_ERROR, environment variable takes the lower precedence.=== hubotApprove
Sends a hubot message the project chat room for a project when the build is waiting for user input with the hubot commands to proceed or abort the build.
required
, actual message to send.optional
, text which can be used in script to differentiate. Ex: INFO, WARN, ERROR or SUCCESS - So that in Slack it can be used to decide card colors.optional
, list of tokens, comma separated, Refer to https://wiki.jenkins.io/display/JENKINS/Token+Macro+Plugin[Token Macro plugin] for more information.optional
, extra data like attachments in case of slack, Any kind of Map, given it is Serializable.optional
, hubot site name either it is from Folder Level or Global Level, Only used when url is not present. Optional, it will fallback to first default site that it found while searching from immediate folder to Global site configurations.optional
, if it is provided as global environment variable HUBOT_URL or provided by withEnv
step, this should always end with /
, environment variable takes the lower precedence.optional
, if it is provided as global environment variable HUBOT_DEFAULT_ROOM or provided by withEnv
step, and room doesn't require #
, it is added in the code, environment variable takes the lower precedence.optional
and by default it is true
, if any error it won't abort the job, it can also be provided as global environment variable HUBOT_FAIL_ON_ERROR, environment variable takes the lower precedence.optional
, defaults to Proceed, refer to https://jenkins.io/doc/pipeline/steps/pipeline-input-step/[input step] for more information.optional
, comma separated list of users who can provide input. Refer to https://jenkins.io/doc/pipeline/steps/pipeline-input-step/[input step] for more information.optional
, Proceed button label, Refer to https://jenkins.io/doc/pipeline/steps/pipeline-input-step/[input step] for more information.optional
If specified, this is the name of the return value that will contain the ID of the user that approves this input. Refer to https://jenkins.io/doc/pipeline/steps/pipeline-input-step/[input step] for more information.optional
, Request that the submitter specify one or more parameter values when approving. Refer to https://jenkins.io/doc/pipeline/steps/pipeline-input-step/[input step] for more information.==== Example
hubotSend message: "Release Started. \n Releasing Test Project. ☀️ \n<!here> <!channel> <@nrayapati> ", tokens: "BUILD_NUMBER,BUILD_ID", status: 'STARTED'
hubotSend message: "Release Completed. \n Releasing Test Project.", tokens: "BUILD_NUMBER,BUILD_ID", status: 'SUCCESS'
hubotApprove message: 'Promote to Staging?', tokens: "BUILD_NUMBER, BUILD_DURATION", status: 'ABORTED'
hubotSend message: "Staging Deployment Successful... \n Deployed Test Project to 192.168.1.175 node.", tokens: "BUILD_NUMBER,BUILD_ID", status: 'SUCCESS'
hubotApprove message: 'Promote to Production?', tokens: "BUILD_NUMBER, BUILD_DURATION", status: 'ABORTED'
Jenkins Approved Job
image::images/slackProceed.png[Slack Example,900]
image::images/proceed.png[Slack Example,500]
Jenkins Aborted Job:
image::images/slackAbort.png[Slack Example,900]
image::images/abort.png[Slack Example,500]
== Hubot Setup
=== New to hubot?
Refer to https://github.com/ThoughtsLive/hubot-base[hubot-base] to setup a either docker container or to run it locally.
TIP: Please replace scripts on hubot-base repo with the scripts under this hubot-steps repo and it is always a good idea to copy over the scripts from appropriate tag based on the version being installed on Jenkins.
=== Already running hubot.
Then just copy over following scripts from scripts
folder (jenkins, and one of the hubot scripts based on chat service you are using.). These are just examples and can be modified based on chat service / per the actual needs.
== Examples
==== Default Site at Folder/Global level.
==== With Site Name either at Folder or Global level.
==== Site with Folder Name as Room.
==== With Global Environment Variables / No Default Site at Folder/Global level. image::images/global.png[Global,900]
==== No Environment Variables
Screenshot:
image::images/pipeline_syntax.png[Pipeline Syntax,900]
== Blue Ocean View
image::images/blueocean.png[BlueOcean,900]
== Known Issues
== Maintainers
== Disclaimer
Please don't hesitate to log a https://issues.jenkins-ci.org/secure/RapidBoard.jspa?rapidView=171&projectKey=JENKINS[JIRA] or github pull request if you need any help or if you can be of help with this plugin :). Refer to the link:./CONTRIBUTION.adoc[contribution guide] for more information.
Developed by https://github.com/nrayapati[Naresh Rayapati], this repo was initially cloned from https://github.com/ThoughtsLive/hubot-steps[ThoughtsLive]