Mark as successful action for builds in Teamcity - teamcity

I have a question to all the experienced Teamcity users out there.
I would like to exit out of a job based on a particular condition, but I do not want the status of the job as a failure. Is it possible to mark a job as successful even when you exit out of the job with an "exit code 1" or any pointers to achieve the same (exit out of a Teamcity job but mark the job as successful) through an alternative way is greatly appreciated!
Thanks!

You can use TeamCity service messages to update build status, e.g. write to the output
##teamcity[buildStatus status='SUCCESS' text='{build.status.text} and then made green']
to get build status text concatenated with the and then made green string.

If you have Command Line Build Step and you are using TeamCity 2017.2 then you can format stderr output as warning. Here is a documentation: https://confluence.jetbrains.com/display/TCD10/Command+Line

Related

In Travis, is it possible to mark a staged as "Cancelled" instead of "Failed" when running a bash script?

There does exist a "Cancelled" state, which you can invoke by clicking on small x next to the job. This is how a cancelled job looks:
Is it possible to enter this cancelled state when running a bash script invoked by your .travis.yml? From Travis docs:
If script returns a non-zero exit code, the build is failed
So returning a different error code doesn't help. Is it just not doable?

Xcode13 how to see pre and post build action logs?

similar question to this thread but that thread is very outdated (Xocde4)
on Xcode13. How do you see logs of a pre and post build action? I am running a script as part of the pre-build action but logs can't be found anymore.
I am not even sure its kicked off - how do I check pre build action its actually invoked?
Resolved a similar issue by forwarding my pre-build logs to a file. I added the next bunch of code to the beginning of my pre-build script.
#/bin/bash
exec > "${PROJECT_DIR}/prebuild.log" 2>&1
set -o pipefail
set -e

How to terminate a Google Cloud Build Pipeline properly?

A pipeline is automatically terminated when any step in pipeline exited with an error code greater than 0. After that the build process is marked as failed. So far so good.
For instance when the current branch is master after some steps such as build and test I want to process some extra steps like tag and deploy. When the current branch is not master these extra steps can be skipped.
One workaround is having a guard on each extra step, which asks for the current branch. But this seems to be inelegant.
How to break a pipeline with exit code 0?
there is nothing 'out of box' yet from cloud builder.
Work arounds are adding if statements
[[ "$REPO_NAME" == "master" ]] && your_command_here
You're going to have to change the entrypoint to a bash shell for this to work

Jenkins always SUCCESS state when the Shell script actually failed

I'm facing this challenge in my current Jenkins setup. Where the set of cases like Shell(bash) script executed remotely:
Permission denied while my installer copied
Unable to connect with SSH
Any suggestion on these cases how can I fix it? any pointers?
Thanks in advance
A pipeline will fail if a script / software returns a value not equal zero. There are programs like Robocopy that execute a command, fail and return a 0. Jenkins does not understand that the program was not successful and marks the pipeline as a success.
Basically this is what you have to do. If your script returns a value not equal zero the pipeline will fail.

After triggering a Jenkins job remotely via a Bash script, when should I retrieve the job id?

I already built a script trigger_jenkins_job.sh which works perfectly fine for now. It’s composed mainly of 3 functions:
input_checkpoint
run_remotejob #: Running Jenkins job remotely using Json api.
sleep 10 #: 10 sec estimated time until pending duration is over
#and Jenkins job start running, i.e. a given slave was
#assigned to run the job.
get_buildID #: Retrieving build state, last build ID and last stable
#build ID using
The problem is I want to get rid of that sleep 10 seconds. And in the same time, I want to be sure before executing the function get_buildID that the remotely- triggered job is actually running on a node.
That way I will be retrieving the triggered job’s id, and not the last one in the queue before triggering that job.
Regarding the Jenkins file of the job, I specified:
agent {
label 'linux-node'
}
So, I guess the question is, I need some how from by bash script, to test if linux-node is running the remotely-triggered job, and if yes I execute the function get_buildID.
Get rid of the sleep command and use the wait command.
If you are triggering Job with tokens,it command itself should return you buildNumber.
Another way could be REST API. Please see "nextBuildNumber" field there (if build is still pending) else "number"

Resources