I have a scenario where I want to submit rundeck jobs via the cli just as if a person was sitting in front of a gui with a keyboard/mouse, to provide an additional way of convenience and automation.
Is there a cli tool for submitting rundeck (relevant doc link would be superb.)
Thanks.
U can refer this github : https://github.com/rundeck/rundeck-cli
also u can build rundeck for your linux from source.
You can use RD CLI tool.
Also, you can execute all Rundeck actions using the API, check this and here to see the full API reference.
I am working on a CI system with Jenkins. But now I got a problem. I need to do the following steps.
1:Jenkins build
2:Deploy to Tomcat
3:find a way to send the build parameters (Job Name, build number...) to a web server (I am using REST now).
4:Web Server trigger testing system.
5:Jenkins get the result from testing system.
6:update build status
7:send emails.
I have problem with the step 3. I need to send those info after the deploy. I am thinking a way as following.
write those parameters to a file during build step, then call a script or Java problem to process the file and send out those info by REST.
But that is ugly. Is there any better ways to do it?
Side questions
Can groovy do this?
How to import groovy http-builder library to Jenkins?
I found a walk around solution.
1: ran echo command during the build to get the build ID and print to log.
2:wrote a small Java program to get the JSON response of the build then sent the necessary info as rest request to the server you set. The program is like a message forwarder.
3:in post build actions, use groovy post build to fetch the log then call the Java program.
I am creating a screenshot when my NUnit end-to-end test fails and I am trying to publish it with TeamCity (build agent and server both running on Windows) using the following service message (as described here) which I am writing with Console.WriteLine from an NUnit test:
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
I see the line in the build log:
------- Stdout: -------
##teamcity[publishArtifacts 'C:\BuildAgent\work\xxxxxxxxxxxxxxxx\Path\To\My\Stuff\fail.png']
But TeamCity is not picking up the file, or at least it is not showing up in the build artifacts. How do I make this work?
Try using relative paths. Teamcity should resolve them against build working directory.
You can try Console.Write instead of Console.WriteLine (see below).
Anyway, I guess TeamCity don't trap these messages because they are 'test reports' and appended in the buildlog as text output.
My feeling is they are not parsed and then not interpreted by the Build Script Interaction behavior because of the way they are flushed into the build log.
From the Build Script Interaction (TC 7) :
Service messages are used to pass commands/build information to
TeamCity server from the build script. In order to be processed by
TeamCity they should be printed into standard output stream of the
build (otherwise, if the output is not in the service message syntax,
it should appear in the build log). A single service message should
not contain a newline character inside it, it should not span across
multiple lines.
You should put your test artifacts in a specific folder and delay the publish after the tests.
Note that if you don't need to resolve artifact dynamically, you should use the simpliest way : the Artifact paths in the build configuration general settings.
Use the NuGet package provided by JetBrains, this takes care of all the subtleties
NuGet Install TeamCity.ServiceMessages
On GitHub: https://github.com/JetBrains/TeamCity.ServiceMessages
Version 2.15 of Jenkins plug-in Email-ext added support for attaching files to build notification e-mails. I would like to have the build log attached to build notification e-mails, but I can't figure out how to do it.
The build log appears to be stored on the Jenkins master node (in this case, Ubuntu Linux). For example, /var/lib/jenkins/jobs/<PROJECT_NAME>/builds/<DATE_TIME>/log. Naturally, the build log path changes with every build. The Email-ext file attachment feature defaults to using files from within the project workspace, which is on the Jenkins slave build machine (in this case, Mac OS X). For example, I configured my slave to use the folder /Users/<USERNAME>/Jenkins/build_agent/workspace/<PROJECT_NAME>/.
Is there any way to get Email-ext to attach a file from the master's file system, instead of the workspace on the slave build machine?
Thanks in advance to anyone who can offer some advice. The Email-ext wiki page currently does not contain an example of how to configure attachments.
You may just use ${BUILD_LOG, maxLines, escapeHtml} token in the body of the e-mail to include the build log.
Quoting the email-ext plugin doc (available here):
"To see a list of all available email tokens and what they display, you can click the "?" (question mark) associated with the Content Token Reference at the top bottom of the email-ext section on the project configuration screen"
The plugin DOES support attaching the build log, you just need to check the box in the project configuration.
After sleeping on the problem and doing more research, I came to the conclusion that Email-ext does not support the attachment of a build log to a build notification e-mail.
However, I did come up with a sneaky work-around to use until such a feature is available: I use the Jenkins build tokens to generate the appropriate command to copy the log file from the master server to the slave's build workspace (see note below).
In the project, after the main compilation step, I added a new Execute shell step to generate the appropriate scp (secure copy) command. This is the command (replace USER and HOSTNAME with your own values, and you'll probably need to tailor the path to suit your individual server):
scp USER#HOSTNAME:/var/lib/jenkins/jobs/$JOB_NAME/builds/$BUILD_ID/log build.log
Then, in the Email-ext Attachments field of the Email-ext plugin, I entered:
build.log
Now the build log is copied from the master to the slave's workspace and attached to build notification e-mail messages. I have removed the $BUILD_LOG token from the message body template.
Note: to use this particular technique, you'll need to have passwordless ssh configured between the slave and the master, perhaps using an OpenSSH key passphrase. If you need help with that, search around the web for information on the ssh-keygen command, and perhaps check tutorials like this one. A similar approach should work on platforms that do not have built-in support for SSH. RoboCopy or similar should work on Windows systems.
EDIT: The Email-ext plug-in now has the ability to attach a build log to a notification message with a check-box on the job's configuration screen. See slide's answer for an example.
When using Jenkinsfile, add attachLog: true to the emailext configuration, like:
emailext attachLog: true, body: '', subject: ''
Credit to #Spencer Malone in Jenkins pipeline - Notify with console error log through email
Firsl of all You have to install Email Ext plugin.After installing follow this step.
Now in to the 'Add post-build action’ select Editable Email Notification and in that section you have option Attach build Log.select option as below in picture.
after that apply and save.Now you will definitely get Build Log in Email attachment.
Thank You.
I have noticed that when i check the box to attach build log, it also unchecks after saving, however it is attached in my emails after the email has been submitted.
I'm trying to integrate Robot Framework (an acceptance testing framework) with TeamCity. In order to do this it needs to send messages to the console output which TeamCity will then read and return realtime test progress/results. I'm doing this by calling the command line to run the tests with a simple exec task. Everything seemed to be working other than I was only getting the results at the end of the run and not on the fly.
After a bit of struggling with NAnt I swapped to using MSBuild and everything worked first time.
I have what I need now, but for completeness I'd like to find out why I couldn't get it working with NAnt. As far as I can tell the issue is that NAnt is prefixing all console output with [exec]. Is it possible to suppress this?
I don't think the console output is configurable.
NAnt is open source: you could fork your own copy and/or submit a feature patch.