Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent build from failing if error occurs #20

Closed
giacgbj opened this issue Dec 14, 2020 · 5 comments
Closed

Prevent build from failing if error occurs #20

giacgbj opened this issue Dec 14, 2020 · 5 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@giacgbj
Copy link

giacgbj commented Dec 14, 2020

Could you add an option in global, per-job and pipeline configurations to prevent the build from failing if an error occurs for whatever reason, for example during the communication with the Dependency-Track instance?
Failing a long build almost completed is very frustrating.

If you want to elaborate on it, you could add the option to select how to mark the build: success, unstable or failure (default, now).

@giacgbj giacgbj added the enhancement New feature or request label Dec 14, 2020
@clausfod
Copy link

For async setup jobs this is "must have". For sync jobs it could be nice that the build did not fail, but instead gave the possibility to be unstable

@sephiroth-j sephiroth-j added bug Something isn't working enhancement New feature or request and removed enhancement New feature or request bug Something isn't working labels Jan 17, 2021
@sephiroth-j
Copy link
Member

Failing the build job if something is wrong with your build environment is a common behavior and it is intended (#9). It is also a signal (to you or Jenkins admin) that there is something abnormal and that needs your attention. If you want to ignore errors and make the job go on, use a pipeline job, wrap the dependencyTrackPublisher call in a try-catch block and do whatever makes you happy when an exception occurred.

Declarative Pipeline example

pipeline {
    agent any

    stages {
        stage('dependencyTrackPublisher') {
		steps {
		        withCredentials([string(credentialsId: '506ed685-4e2b-4d31-a44f-8ba8e67b6341', variable: 'API_KEY')]) {
				script {
					try {
						dependencyTrackPublisher artifact: 'target/bom.xml', projectName: 'my-project', projectVersion: 'my-version', synchronous: true, dependencyTrackApiKey: API_KEY
					} catch (e) {
						echo 'failed'
					}
				}
			}
		}
        }
    }
}

Scripted Pipeline example: see README

@sephiroth-j sephiroth-j added the wontfix This will not be worked on label Jan 18, 2021
@clausfod
Copy link

Thanks for that input. There is a lot of plugins for Jenkins supporting returning a response code when used, IMHO that would be much cleaner as this leaves the pipelines "in good shape" as you are able to create all you pipeline logic without a lot of try catches on different plugins.

It could be as simple as returning the HTTP code.

@rvsoni
Copy link

rvsoni commented Mar 3, 2021

Hi @giacgbj

I face the same issue, I fix the code on my fork (rvsoni@eee4259)

I introduced an option on the global config advance section, also on job config, that can help you to just upload a BOM and not wait for the result, this would mark build success.

Pl. build this code and test it, Pl. let me know if there are any improvements,

Ravi

@rvsoni
Copy link

rvsoni commented Mar 5, 2021

It prints the below logs on Jenkins and does not wait to collect the result. ```

Waiting for Jenkins to finish collecting data
channel stopped
[DependencyTrack] Publishing artifact to Dependency-Track - https://dtrack.example.com
[DependencyTrack] Not waiting for project analysis result.
[JaCoCo plugin] Collecting JaCoCo coverage data...

Ravi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants