Mail Commander plugin in Jenkins cannot trigger Parameterized build - plugins

I am trying to build parameterized jobs in Jenkins through Mail commander plugin.
As per the documentation of the plugin I have configured it. It triggers stand alone jobs which don't need any parameters.
It also builds parameterized jobs but with default values.
MailCommander plugin reads the subject and builds the specific trigger.
I give the command as "build jobname -p key=value -p key=value" but the MailCommander just ignores the parameters.
Please let me know if there is some other configuration that I have to do.

Related

How to run Jenkins Groovy scripts directly from Intellij or Eclipse

I have a Groovy repository which contains my Jenkins pipeline's Groovy code.
Currently, I am making changes in an IDE, commiting them to the repository, going to the Jenkins instance, manually triggering a Jenkins job, and checking to see if all of the changes all working. This is taking a lot of time.
Is there a way to do all of this from the IDE itself?
I would suggest to treat your pipeline code like some other code in IT. What are you doing now could be called "manual integration tests" because you are making your code changes and check how that code integrate with other components (like shell commands, jenkins plugins, etc.) on jenkins - this development loop is long and not efficient. So my proposition for you is to write simple unit tests using this framework:
https://github.com/jenkinsci/JenkinsPipelineUnit
So you can test your pipelines on your machine without any interaction with jenkins.
If you think that it's not proper way for you I would suggest to mix using this plugin for running jobs directly from IntelliJ: https://github.com/programisci/jenkins-control-plugin/
and of course IntelliJ git integration to commit your changes to repository.
For executing from the IDE, an option is to create some automation around using the Jenkins CLI. You should be able to see the CLI commands at http://your-jenkins-url/cli.
java -jar jenkins-cli.jar -s https://jenkins.physiq.zone/ replay-pipeline JOB [-n (--number) BUILD#] [-s (--script) SCRIPT]
Replay a Pipeline build with edited script taken from standard input
JOB : Name of the job to replay.
-n (--number) BUILD# : Build to replay, if not the last.
-s (--script) SCRIPT : Name of script to edit, such as Script3, if not the main Jenkinsfile.
For example, in IntelliJ you could use a Run Configuration that:
Downloads the CLI JAR
Executes it with the path to the local file with certain parameters
You can also write a script, Gradle build, or something else that wires into the IDE to pull the CLI JAR and execute a job with your local pipeline code.
For testing you may want to use https://github.com/jenkinsci/JenkinsPipelineUnit as already brought up, or a Gradle plugin that I maintain at https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin which uses the previously mentioned library for unit testing and the jenkinsci/jenkins-test-harness for integration testing.

Fail/pass Jenkins job by email notification

We have an in-company system for creating production builds, and I need to create a Jenkins job to automate those builds.
There is a way to automate the launch of production build. But you can only know the results of the build by an email notification. Furthermore, you can only subscribe to notification using your personal domain credentials, i.e. the same login/pass that you use to log into your computer (and the password changes every month).
So now, Jenkins job is considered "pass" as soon as the build launches, and not when it actually finishes.
I wonder how to make Jenkins pass/fail the job with the given restrictions.
Additionally, I want to avoid:
hardcoding my personal credentials anywhere,
depending on my or anyone else's personal computer being turned on.
Ideas?
I'm not aware of any Jenkins plugin that is capable of receiving e-mails.
If you can manage to store the notifications' content in a file you could use the
Text-finder Plugin in the Post-build Actions of an additional monitor job that runs on a regular basis.
Have a look at Monitoring external jobs, too, whether this is useful for you.
UPDATE:
There is actually a plugin that receives e-mails: the poll-mailbox-trigger-plugin. Install it and do the following:
Create a new Freestyle project named e.g. Build Status Mail Monitor
Build Triggers → [✔] [Poll Mailbox Trigger] - Poll an email inbox
configure as desired
Build → Add build step → Execute Groovy script
◉ Groovy command: add code to change build launcher job's status

How to test Jenkins Workflow

Is there an example of how to do testing against the Jenkins Workflow groovy DSL?
Something similar to the example for the Jenkins Job DSL.
What I've done, is that I created a complete dev-test environment. I did it by using a docker-compose file that includes: jenkins, gitlab, and archiva. I push to a "jenkins-test" origin and run the workflow in the safe "test" environment.
Here's my docker-compose in case someone is interested as a starting point, or as a simple test env:
https://github.com/portenez/dry-dock
it's not fully automated, but it's a good start.
No, running a workflow script requires Jenkins to actually be running (since most of what it does is interact directly with Jenkins features like slaves and test results), so the only way to test it is to have a test Jenkins server and run it. By far the most convenient ways to do that in a fully automated way are:
Use JenkinsRule in the Jenkins test harness, like plugins would do in their test sources. Example
Use the acceptance-test-harness project as a dependency to create integration tests driven via Selenium. Example

How to put jobs in a category for the Throttle Concurrent Builds plugin for Jenkins

I have downloaded the TCB plugin for Jenkins. I have several builds that run tests. These builds must be run individually, as they access similar files that can cause tests to fail if more than one test build is running. I have been trying to find the place where I put the builds into a "category", so I can throttle the whole test category down to 1/1. I thought that it might be the Jenkins Views, but that did not do the job. How do you add jobs to a category?
This tag discusses the solution I desire: Jenkins: group jobs and limit build processors for this group. The only problem is that it doesn't say how to add them to categories.
You set up categories in the global Jenkins configuration (Manage Jenkins -> Configure System) and then assign jobs to categories. See the "Per Project-Category" section in the plugin documentation.

Trigger a build in Bamboo from a Jenkins job

Currently all our Regression tests are configured in a Jenkins job.We want once the regression tests are completed,it should trigger a plan in our Bamboo server and also record the tests results in Bamboo using TestNG parser.Is it possible?
Ps : I have already seen Bamboo rest-api but can not seem to find a solution.Any suggestions will be highly appreciated.Thanks
It hasn't been updated for a while and I'm not using it currently, thus can't confirm it is still working as desired (the download statistics suggest it being used though), but given there's not much to it, you should be able to achieve the first part of your use case with the Bamboo Notifier, which allows you to Trigger a Bamboo build upon successful completion of a Jenkins job.
The second part should be covered by the Bamboo TestNG Parser task, though you'll need to push your existing test result files to Bamboo by some means of course, possibly by Using the SCP task in Bamboo.