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

Add a probe for failing builds on the default branch #363

Open
NotMyFault opened this issue Aug 31, 2023 · 6 comments · May be fixed by #422
Open

Add a probe for failing builds on the default branch #363

NotMyFault opened this issue Aug 31, 2023 · 6 comments · May be fixed by #422
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers probe Related to probe implementation

Comments

@NotMyFault
Copy link
Member

Description

If the project has as Jenkinsfile in the root directory, the probe should obtain the build status published through the checks API, whether it fails on ci.jenkins.io or not.

Failing builds on the default branch are a good indicator, that the project is in a bad state and requires (maintainer) attention.

@NotMyFault NotMyFault added enhancement New feature or request probe Related to probe implementation labels Aug 31, 2023
@alecharp alecharp added the good first issue Good for newcomers label Sep 22, 2023
@AayushSaini101
Copy link
Contributor

Hi, @NotMyFault @alecharp I want to take this issue. can you please assign to me ?

@AayushSaini101
Copy link
Contributor

AayushSaini101 commented Oct 2, 2023

There is a probe already written that is JenkinsfileProbe. I guess this is the extend probe. we need to check only the default branch is build status

@AayushSaini101
Copy link
Contributor

@NotMyFault @alecharp Do we have any specific documentation to understand the different libraries used in the plugin? I understand most of the, but I have not been able to find a way to interact with the default branch and fetch the build status.

final Path repository = context.getScmRepository();
      try (Stream<Path> paths = Files
          .find(repository, 1, (file, basicFileAttributes) -> Files.isReadable(file) && "Jenkinsfile".equals(file.getFileName().toString()))
      ) {
          return paths.findFirst()
              .map(file -> ProbeResult.success(key(), "Jenkinsfile found"))
              .orElseGet(() -> ProbeResult.failure(key(), "No Jenkinsfile found"));
      } catch (IOException e) {
          return ProbeResult.error(key(), e.getMessage());
      }

The New probe seems like to similar just need to add the status of the check API in the return statement, but i cannot able to figure out what is check API ? Can you please guide me a little bit

@alecharp
Copy link
Collaborator

alecharp commented Oct 3, 2023

Hello @AayushSaini101.

Do we have any specific documentation to understand the different libraries used in the plugin?

Well no, each library we use have their own documentation, which we don't duplicate in this project.

To get the default branch of a plugin, you can see that you can find that information in the GitHub API, more specifically in the GHRepository class. To interact with GitHub API, we use https://github.com/hub4j/github-api. Please see its documentation and maybe you need to browse its source code to have a better grasp at what you can do with it.

@AayushSaini101 AayushSaini101 linked a pull request Dec 25, 2023 that will close this issue
1 task
@Peakycode99
Copy link

hello, @NotMyFault @alecharp , i can fix this issue. can you please assign me.

@AayushSaini101
Copy link
Contributor

hello, @NotMyFault @alecharp , i can fix this issue. can you please assign me.

@Peakycode99 Hi I have already made a PR I will try to complete by this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers probe Related to probe implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants