Suspending a Travis build - travis-ci

I have a travis.yml script as part of a package on my github site. So every time I push an update, it is automatically rebuilt and checked. However, sometimes I know it won't build correctly and I am just pushing my changes to keep from losing them.
Another incentive for suspending a build is that I literally cringe when I receive an e-mail with a subject line saying it has "errored." I wish somebody would tell this Travis guy that "error" is a noun, not a verb.

The best way to handle your travis build would be to setup a branch where the build is trigger and to build in another branch. This way, you will do what you want and only trigger the build when you will do a merge.
About the verb errored, it isn't currently a verb. But it will maybe be, like to google.
error (third-person singular simple present errors, present participle erroring, simple past and past participle errored)
(computing) To function improperly due to an error, especially accompanied by error message.
The web-page took a long time to load and errored out.
Remove that line of code and the script should stop erroring there.
This directory errors with a "Permission denied" message.

Related

How to get Jenkins lastBuild API working with multi-branch pipelines?

I've had no problems getting last build details out of Jenkins in the past, but I've struck a weirdly-configured corporate environment, where the API urls are structured like this:
https://example.com/job/group-name/job/project-name/api/json
I can find the last build for a specific branch in this heirarchy:
https://example.com/job/group-name/job/project-name/job/branch-name/lastBuild/api/json
But how to get the last build of a project regardless of branch has defied all my efforts so far.
I can tell you that the obvious (and all non-obvious variations that I've tried) truly, seriously don't work. For instance, this is a complete failure:
https://example.com/job/group-name/job/project-name/lastBuild/api/json
And returns "This page isn’t working example.com redirected you too many times."
I'm guessing that the multiple copies of /job/ in the working URLs are a symptom of an unusual structure, so if anyone has any ideas I'm all ears!

How to start a build via a phrase in Jenkins Pipelines

I am switching from the github pull request builder plugin (for security reasons) and am trying to get the same functionality from Pipelines (using different plugin). I think I have just about everything, however I can't seem to find a way to re-trigger a build simply by a trigger phrase like in github pull request builder plugin. Is that possible via pipelines?
By trigger phrase, I mean that a user can make a comment on the PR saying "Jenkins re-test" and it will kick off the build again.
You can put a condition at the top of the build script to check for the message. You can access the changesets using currentBuild.ChangeSets. The last changeset is at the end of the array. Then you need to access the last element of that changeset. Finally you can access the message via message property. You can then search for your keyword.
I am doing the opposite (not triggering the build with a phrase) but never tried for pullrequests though.
Another idea is to use the "ignore builds with specific message" property and setting this message to be a regex with look ahead that accepts everything except the keyword. I don't really recall the syntax though :/

Jenkins pipeline: How to prompt "Do you really want to build?"

We are using Jenkins with Pipeline Jobs and of course the awesome Jenkinsfile.
Twice now a developer accidentally clicked on the build button, which ended up causing a bit of chaos. I am trying to figure out if it is possible to have something like a popup that asks "Do you really want to start this build?".
Any ideas on this user related issue are welcome.
Have a look at the article Controlling the Flow with Stage, Lock, and Milestone in the Jenkins blog, which covers a bit more than only asking for confirmation.
Essentially, there is the input step, which requires user input to continue pipeline execution.
The problem with the input step as suggested by StephenKing is that you won't be able to run the build automatically anymore as it will always ask for the user to confirm the input step manually. This prevents "automatic builds" triggered e.g. by webhooks or CRON jobs.
One workaround is to have a timeout and the build is triggered if the timeout is over. Like that, a user can at least abort an unintended build. But this leads to significantly longer build times.
What we did in my old company was, that we created a so called "parametrized" build, which had a simple checkbox "Do you really want to build this job" that resulted in a flag REALLY_BUILD as an environment variable. You can then ask for ${REALLY_BUILD}==1 in the Jenkinsfile. Every time a developer triggers a build, he has to check the box, otherwise the build will not start / immediately stop.
When you trigger your job via a webhook, you can pass a parameter REALLY_BUILD as an URL parameter (see this comment in the Jenkins tracker) and access it in the Jenkinsfile as before.
Here is another resource for how to use parameters in Pipelines.

CircleCI never completes

I have a Ruby/Rails project I inherited. It's a private github repo, and it's hooked up to CircleCI in the standard way: github won't allow a merge til the required CircleCI tests pass. That's fine, but when I create a pull request, I only get "ci/circleci — Waiting for status to be reported" and that never changes (I waited all weekend). I'm not sure where to look for log files, or what might be going wrong. I'm new to CircleCI. Any help? The last item I see in my circleci dashboard is months ago, so it's almost like it's not seeing the new pull request. But I can see github sending it and getting a 200 reply.
BTW, the circle.yml just sets the machine timezone, nothing else, nothing fancy.
You may need to configure the branch settings:
https://circleci.com/docs/2.0/workflows-waiting-status/

Stop/abort Build the moment certain text is encountered in console output

Bottom line on top: Is there a way to halt a build immediately when a certain string is encountered in the console output?
We have a maven build that uses the maven target site-deploy (it uploads java doc to a remote server via ssh).
Every once in a blue moon a build fails, and as a result of this failure, the console output file is ~12+ gigs, which files up our drive, which in turn, can cause our Jenkins master to die due to out of diskspace.
The log file gets filled up with the following message repeated over and over again:
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
3d:69:41:8a:ec:d1:4c:d9:75:ef:7d:71:b7:7d:61:d0.
Please contact your system administrator.
Add correct host key in known_hosts to get rid of this message.
Do you want to delete the old key and insert the new key? (yes/no):
We are in the process of fixing the build so that we don't get this error message, but it would really cool if Jenkins can stop/abort the build the moment it encounters this message.
Is there a way to do this?
I don't know any existing solution, but I believe it should be possible to write your own plugin to do so.
You could create a BuildWrapper that decorates the log and searches for your messages, then kill the build when it matches your criteria.
Here's a BuildWrapper that kills a job that has been running too long:
The plugin
The implementation

Resources