How can I trigger jenkins jobs with a slack bot? - jenkins

I have Jenkins running on one of the VMs on GCP. I have a bunch of jobs and I want to give my team access to run them from Slack. They haven't used Jenkins earlier, and not at all familiar with the UI. So, they want to run it from Slack. We already have a slack bot. So, here are my following questions:
Can I integrate our existing slackbot with jenkins, so that it can trigger the jobs? If yes, how can I do it? (any tutorial would be greatly appreciated)
I know there is a way to do this with slash commands. But I don't want run a different command for each job, it's actually not really clean. Cause if I have 20 jobs, I have to create tokens for all of them, and configure 20 slash commands.
What are the other ways of triggering Jenkins jobs from Slack?
PS: I'm looking for something like #bot run "job" "parameter" or #bot run "job". And it would be great if the bot can tag the user and respond to a request

you have to create a slack app for this and enable events and interactivity.
https://api.slack.com/apis/connections/events-api#the-events-api__subscribing-to-event-types__events-api-request-urls__request-url-configuration--verification__url-verification-handshake

Related

How to trigger Jenkin Jobs from Microsoft Team Channel?

I am looking to trigger Jenkins's job from the Microsoft team's channel. Can anyone provide step by step implementation of this?
There are two nice options you can use:
Outgoing Webhook - Will scan for words in the chats and send a notification to your Jenkins server.
Commander - Second and more customizable option is using the Commander add on for teams, which in addition to builtin commands provides the ability to Create your own Custom Commands.
With both options you will be able to tigger Jenkins jobs via the Remote Access API, see the This Question for additional info on remote execution.

What is the best way to generate events from Jenkins?

I have a series of jenkins pipeline jobs to move Apps to Cloud Foundry. My client application need to be able to listen to all the updates of a push. I.e. apart from getting text logs, i need other events like Git repo cloned, cloud foundry logged in, App pushed.
One crud way of doing this is to submit POST requests to an event server from a shell script(Curl). However, I think it is unlikely that such a functionality does not exist already on Jenkins(either through a plugin or something like that).
I need an advice from best practices point of view.
Thanks.
As commented by mdabdullah. But this needs a person to set up kibana or splunk. (I did not try this).
Statistics gatherer plugin
https://plugins.jenkins.io/statistics-gatherer/
Jenkins notification plugin
https://plugins.jenkins.io/notification/
Both 2,3 are available plugins in the Jenkins community. They need to configured for server endpoints before use.

Can you use TFS API with only query strings? Trying to queue build from Slack

Using On-Premise TFS 2017 and Slack. Just trying to find a way for people to manually queue builds. Slack Slash Commands will almost work, but can't seem to send JSON bodies, so I'm trying to find out how to send credentials and definition IDs using only query strings...
Some background:
Our people cannot run unsigned Powershell Scripts because of Group Policy overrides for ExecutionPolicy.
Don't want to give people access to queue builds through web interface.
We are using CI/CD, but need to manually queue for QA/Demo builds.
Wanted to avoid using another app as a go-between if possible, since new environments for hosting are hard to come by here.
Is there a way to hit the TFS API through Slack Slash Commands?

How to trigger a jenkins build from slack via middleware

I am trying to trigger a Jenkins build from Slack and it looks like I might have to write new Middleware. Can anyone help with this as I am not really strong in programming and scripting?
There is a pretty detailed blog post here by Nguyen Sy Thanh Son that delineates how to do this in detail. At a high level, it basically comes down to configuring your Jenkins job so that it can be triggered remotely and creating a new Slack command that triggers the Jenkins job.

JIRA Integration with external systems

I'm working on a POC to automate downstream processes in external systems based on JIRA processes and have hit a wall with the API. It appears to have great integration for pulling data about tickets out of JIRA and for the ability to externally generate tickets into JIRA.
However I don't see how to trigger external calls as a part of my workflows. For example if a ticket should be prevented from being routed to the next stage of a workflow without accessing a database to ensure availability of inventory first how could I do that in JIRA?
Based on attributes in the JIRA ticket upon final completion of the workflow we'd like to send a JMS or REST message or possibly update an external database. Is this possible?
Thanks all in advance for the help!
If you want to do a "before" check, use a Validator on the Workflow Transition.
I strongly suggest deploying the (free) Script Runner add-on. There you can implement a ton of things. For example, you'll get a new validator option "Script Validator", where you can specify a Groovy script that decides if it lets through the transition or aborts it.

Resources