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

[JENKINS-34410] Improved the search procedure of through SCMSourceCriteria #50

Merged
merged 5 commits into from Apr 27, 2016

Conversation

recena
Copy link
Contributor

@recena recena commented Apr 21, 2016

JENKINS-34410

This is an alternative to jenkinsci/workflow-multibranch-plugin#3

  1. Better management of log message
  2. Only one request to GitHub API

@reviewbybees

@ghost
Copy link

ghost commented Apr 21, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@recena recena changed the title Improved the search of SCRIPT_FILE (aka Jenkinsfile) Improved the search procedure of through SCMSourceCriteria Apr 21, 2016
@amuniz
Copy link
Member

amuniz commented Apr 21, 2016

No strong opinion, but by design #50 is better as SCMSource implementations should limit themselves to answer the given question: does this path exist? - without making any assumption.

@recena
Copy link
Contributor Author

recena commented Apr 21, 2016

This is a strong opinion since you have two alternatives and choose one of them.

In the ticket description there are two positive things. IMO, this alternative is still better.

@recena
Copy link
Contributor Author

recena commented Apr 21, 2016

does this path exist?

Exactly, I reply to this question and additionally, provide more contextual information to cover specific scenarios.

@amuniz
Copy link
Member

amuniz commented Apr 21, 2016

This is a strong opinion

Well, not really, as I'm ok with this to be merged too (it's an opinion, but not strong 😄 )

@stephenc
Copy link
Member

🐝 if you value my opinion

@recena
Copy link
Contributor Author

recena commented Apr 21, 2016

@stephenc your opinion is always welcome!

@recena
Copy link
Contributor Author

recena commented Apr 22, 2016

Although this PR is ready to be merged, I prefer to wait the @jglick's opinion.

@jglick
Copy link
Member

jglick commented Apr 22, 2016

This is an alternative to #50

Huh? This is #50! Did you mean an alternative to jenkinsci/workflow-multibranch-plugin#3?

return true;
}
if (content.getName().equalsIgnoreCase(path)) {
listener.getLogger().format(" %s not found (but found %s, search is case sensitive) in this %s, skipping", path, content.getName(), thing);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to use ‘%s’ to make it clearer that we are quoting pathnames here.

@jglick
Copy link
Member

jglick commented Apr 22, 2016

🐝 assuming you tried it and it seems to behave nicely. Looks right.

@recena
Copy link
Contributor Author

recena commented Apr 22, 2016

Huh? This is #50!

My mistake, too many PRs at the same time 😵

I meant jenkinsci/workflow-multibranch-plugin#3

@recena
Copy link
Contributor Author

recena commented Apr 22, 2016

Please, find an example:

Started
Connecting to github.com with no credentials, anonymous access
Looking up recena/workflow-helloworld

  Getting remote branches...

    Checking branch JENKINS-33306
      ‘Jenkinsfile’ exists in this branch
    Met criteria
Scheduling build for branch: JENKINS-33306

    Checking branch master
      ‘Jenkinsfile’ exists in this branch
    Met criteria
Scheduling build for branch: master

    Checking branch sensitive
      ‘Jenkinsfile’ not found (but found ‘jenkinsfile’, search is case sensitive) in this branch, skipping
    Does not meet criteria

  2 branches were processed

  Getting remote pull requests...

  0 pull requests were processed

Done examining recena/workflow-helloworld

Finished: SUCCESS

@recena
Copy link
Contributor Author

recena commented Apr 22, 2016

@jglick Your re-bee would be fine if you agree with my last commit.

}
listener.getLogger().format(" %s does not exist in this %s%n", path, thing);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to put quotes around the pathname here for consistency with the other two messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick Addressed here 845e33e

@recena
Copy link
Contributor Author

recena commented Apr 26, 2016

@jglick I did some tests:

Lanzada por el usuario anonymous
Connecting to github.com using recena/****** (recena GH PAT)
Looking up recena/workflow-helloworld

  Getting remote branches...

    Checking branch JENKINS-33306
      ‘mymagicfolder/Jenkinsfile’ does not exist in this branch
    Does not meet criteria

    Checking branch master
      ‘mymagicfolder/Jenkinsfile’ does not exist in this branch
    Does not meet criteria

    Checking branch sensitive
      ‘mymagicfolder/Jenkinsfile’ not found (but found ‘jenkinsfile’, search is case sensitive) in this branch, skipping
    Does not meet criteria

  0 branches were processed

  Getting remote pull requests...

  0 pull requests were processed

Done examining recena/workflow-helloworld

Finished: SUCCESS

@recena
Copy link
Contributor Author

recena commented Apr 26, 2016

@jglick Do you agree? 8fcc303

}
if (content.getName().equalsIgnoreCase(filename)) {
listener.getLogger().format(" ‘%s’ not found (but found ‘%s’, search is case sensitive) in this %s, skipping%n", path, content.getName(), thing);
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐜 not quite right, since if you have a repo with both Jenkinsfile and jenkinsfile you would want to return true, even if we encountered jenkinsfile first. Unlikely, but at any rate would be more correct to delete this statement and let it fall through to the end of the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick I thought about it but I decided not to considerer it. As you always say Do not add code if there are not real use cases at least you say that for new API, etc...

This PR improves a real use case that I found few weeks ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this is a corner case easily diagnosable by the user looking at the logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I brought it up mainly because it is a regression: before this PR the branch would correctly be recognized, now it will not. As noted, it is unlikely to occur, and easily enough diagnosed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jglick I prefer the positive things that this PR provided than the hypothetical issue it would be having a repository with both Jenkinsfile and jenkinsfile.

@jglick
Copy link
Member

jglick commented Apr 26, 2016

🐝

@amuniz
Copy link
Member

amuniz commented Apr 27, 2016

re-:bee:

@recena recena merged commit a10e869 into jenkinsci:master Apr 27, 2016
@recena recena changed the title Improved the search procedure of through SCMSourceCriteria [JENKINS-34410] Improved the search procedure of through SCMSourceCriteria Apr 27, 2016
dubrsl pushed a commit to dubrsl/github-branch-source-plugin that referenced this pull request Oct 17, 2020
* Initialize transient fields after XStream deserialization

* Re-wrote test to actually restart Jenkins

* Replace RestartableJenkinsRule.addStep(Statement) with .then(Step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants