patternMinor
Pass string to Jenkins job from Slack
Viewed 0 times
slackpassjenkinsfromstringjob
Problem
In an ideal world our less tech-knowledgeable employees could just use a Slack command to run a job and get the results slacked back to them, negating the use of the Jenkins GUI. I found Start a build in Jenkins using a Slack Command on GitHub, but it's got a few limitations including that it seems to require a 1:1 ratio Heroku instance to Jenkins job, which isn't great for our purposes.
My thought is to have people use a singular command like
The issue falls in getting the parameters to Jenkins. I'm picturing something like the following workflow;
-
User types
-
Command is somehow sent to the umbrella jenkins job. Heroku instance, direct integration, w/e.
-
Umbrella job receives
-
Umbrella job splits the string if it hasn't already been done, and figures out that the user wants
-
Umbrella job does a buildjob to run the downstream job as called, which will Slack back to the user their results.
It's steps 2-3 that are tripping me up. How can I pass a string (with spaces!) from Slack to my Jenkins job?
If my entire premise is wrong I'm also open to having my frame challenged.
My thought is to have people use a singular command like
/jenkins, and use parameters after it that will be parsed by one job, and used to kick off others downstream. That keeps us to one slack command / one instance, but still gives us all the flexibility we need.The issue falls in getting the parameters to Jenkins. I'm picturing something like the following workflow;
-
User types
/Jenkins job2 param1 param2 in Slack. This is calling an umbrella job that will parse the parameters to find out what to run. -
Command is somehow sent to the umbrella jenkins job. Heroku instance, direct integration, w/e.
-
Umbrella job receives
job2 param1 param2 as a string. (Perhaps as the value of a single parameter, perhaps pre-split into multiple fields)-
Umbrella job splits the string if it hasn't already been done, and figures out that the user wants
job2 run, using parameters param1 and param2. -
Umbrella job does a buildjob to run the downstream job as called, which will Slack back to the user their results.
It's steps 2-3 that are tripping me up. How can I pass a string (with spaces!) from Slack to my Jenkins job?
If my entire premise is wrong I'm also open to having my frame challenged.
Solution
The plugin you found doesn't have a 1:1 ratio between Heroku instance with build jobs since it takes the job name as parameter, so you should be able to run any number of jobs from a single Heroku instance.
As for passing a space in a job parameter, the word split is made on spaces so quoting won't change anything. You could possibly try to use the HTML spacing character
Personally I would try to use the plugin to run the correct job with the associated parameters directly instead of going through filtering jobs.
As for passing a space in a job parameter, the word split is made on spaces so quoting won't change anything. You could possibly try to use the HTML spacing character
%20 and see if it works?Personally I would try to use the plugin to run the correct job with the associated parameters directly instead of going through filtering jobs.
Context
StackExchange DevOps Q#1095, answer score: 5
Revisions (0)
No revisions yet.