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

Fix a logical flaw when deleting a build in the jenkins_build module #5514

Merged
merged 12 commits into from
Nov 10, 2022

Conversation

unnecessary-username
Copy link
Contributor

SUMMARY

At present, after deleting a Jenkins build, the code tries to get the build status of the Jenkins build then judge the success/failure of the deletion. When the Jenkins build is successfully deleted, supposedly Jenkins will throw a jenkins.JenkinsException when fetching the build status, but currently the get_build_status() function will catch the exception then directly return a failure json which is a logical flaw.

Considering that deleting an already non-existent build can throw exceptions in the absent_build() function, I plan to adjust the judging logic in the get_build_status() and the get_result() function to fix this logical flaw in identifying the result of deleting an existing Jenkins build.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

jenkins_build

ADDITIONAL INFORMATION

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) tests tests unit tests/unit web_infrastructure needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Nov 9, 2022
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-5 labels Nov 9, 2022
@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Nov 9, 2022
@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Nov 9, 2022
@github-actions
Copy link

github-actions bot commented Nov 9, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Nov 10, 2022
@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Nov 10, 2022
@felixfontein felixfontein changed the title Fix the logical flaw when deleting a build in the jenkins_build module Fix a logical flaw when deleting a build in the jenkins_build module Nov 10, 2022
@felixfontein felixfontein merged commit 7610501 into ansible-collections:main Nov 10, 2022
@patchback
Copy link

patchback bot commented Nov 10, 2022

Backport to stable-5: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 7610501 on top of patchback/backports/stable-5/7610501c66a704214091aa0ba89065a53719f9cd/pr-5514

Backporting merged PR #5514 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/community.general.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-5/7610501c66a704214091aa0ba89065a53719f9cd/pr-5514 upstream/stable-5
  4. Now, cherry-pick PR Fix a logical flaw when deleting a build in the jenkins_build module #5514 contents into that branch:
    $ git cherry-pick -x 7610501c66a704214091aa0ba89065a53719f9cd
    If it'll yell at you with something like fatal: Commit 7610501c66a704214091aa0ba89065a53719f9cd is a merge but no -m option was given., add -m 1 as follows intead:
    $ git cherry-pick -m1 -x 7610501c66a704214091aa0ba89065a53719f9cd
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Fix a logical flaw when deleting a build in the jenkins_build module #5514 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-5/7610501c66a704214091aa0ba89065a53719f9cd/pr-5514
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Nov 10, 2022
@patchback
Copy link

patchback bot commented Nov 10, 2022

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/7610501c66a704214091aa0ba89065a53719f9cd/pr-5514

Backported as #5531

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein
Copy link
Collaborator

@unnecessary-username thanks a lot for your contribution!

patchback bot pushed a commit that referenced this pull request Nov 10, 2022
…5514)

* Fix the logical flaw when deleting a build in the jenkins_build module.

* Fix the logical flaw when deleting a Jenkins build in the jenkins_build module.

* Adding changelogs.

* Update tests/unit/plugins/modules/test_jenkins_build.py

Co-authored-by: Felix Fontein <[email protected]>

* Attempt to mock the exception classes.

* Remedy the CI issues when mocking the exception classes.

* Assuming a way to mock the get_build_status function.

* Near to the feasible approach.

* Calls the correct class when unit testing.

* Fix sending wrong arguments when unit testing.

* Directly assign the argument value in the unit testing.

* Fix errors calling different classes.

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 7610501)
felixfontein pushed a commit that referenced this pull request Nov 13, 2022
…5514) (#5531)

* Fix the logical flaw when deleting a build in the jenkins_build module.

* Fix the logical flaw when deleting a Jenkins build in the jenkins_build module.

* Adding changelogs.

* Update tests/unit/plugins/modules/test_jenkins_build.py

Co-authored-by: Felix Fontein <[email protected]>

* Attempt to mock the exception classes.

* Remedy the CI issues when mocking the exception classes.

* Assuming a way to mock the get_build_status function.

* Near to the feasible approach.

* Calls the correct class when unit testing.

* Fix sending wrong arguments when unit testing.

* Directly assign the argument value in the unit testing.

* Fix errors calling different classes.

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 7610501)

Co-authored-by: Tong He <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) tests tests unit tests/unit web_infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants