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

Adding support for Gitlab #149

Merged
merged 9 commits into from
Sep 8, 2020
Merged

Conversation

Prsna23
Copy link
Contributor

@Prsna23 Prsna23 commented Aug 16, 2020

  • Adding gitlab pr plugin to trigger builds for GitLab merge requests.

<about>
<name>Gitlab Pull Requests Builder</name>
<version>${version}</version>
<target-go-version>15.1.0</target-go-version>
Copy link
Owner

Choose a reason for hiding this comment

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

You might want to update this to a more latest version since you're using more latest JDK dependency :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure will update the version.

Comment on lines 9 to 10
<name>Ashwanth Kumar</name>
<url>https://github.com/ashwanthkumar/gocd-build-github-pull-requests</url>
Copy link
Owner

Choose a reason for hiding this comment

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

Please consider adding your name to this. This is your work and you deserve the credit!


PullRequestStatus prStatus = null;
boolean isDisabled = System.getProperty("go.plugin.gitlab.pr.populate-details", "Y").equals("N");
LOG.debug("Populating PR details is disabled");
Copy link
Owner

Choose a reason for hiding this comment

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

This log should be inside a if (isDisabled) block isn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes will change it 👍

gitConfig.setPassword(props.getProperty(PASSWORD));
}
} catch (IOException e) {
// ignore
Copy link
Owner

Choose a reason for hiding this comment

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

Please always throw an exception so it bubbles up on the Server Dashboard with the error Message. Wrap all exceptions inside a RuntimeException.

Comment on lines 46 to 54
public void addConfigData(GitConfig gitConfig) {
try {
Properties props = GitLabUtils.readPropertyFile();
if (StringUtil.isEmpty(gitConfig.getUsername())) {
gitConfig.setUsername(props.getProperty(LOGIN));
}
if (StringUtil.isEmpty(gitConfig.getPassword())) {
gitConfig.setPassword(props.getProperty(PASSWORD));
}
Copy link
Owner

Choose a reason for hiding this comment

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

Can you also please update the README with the format of the config file and how to setup the plugin?

@ashwanthkumar
Copy link
Owner

I think apart the above things, we're good to merge this into master and cut a release!

Comment on lines 122 to 123
LOG.warn(e.getMessage(), e);
} return null;
throw new RuntimeException(String.format("Failed to fetch PR status. %s", e.getMessage()), e);
Copy link
Owner

Choose a reason for hiding this comment

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

It would be nice to have the log and error have the same message so it is easier to grep on the logs when needed.

@@ -65,7 +64,7 @@ public boolean isValidURL(String url) {
@Override
public void checkConnection(GitConfig gitConfig) {
try {
loginWith(gitConfig).getProjectApi().getProjects();
loginWith(gitConfig).getProjectApi().getProject(GHUtils.parseGithubUrl(gitConfig.getEffectiveUrl()));
} catch (Exception e) {
throw new RuntimeException(String.format("check connection failed. %s", e.getMessage()), e);
Copy link
Owner

Choose a reason for hiding this comment

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

Please consider logging the exception before throwing them.

} catch (IOException e) {
// ignore
} catch (Exception e) {
throw new RuntimeException(String.format("Adding config data failed. %s", e.getMessage()), e);
Copy link
Owner

Choose a reason for hiding this comment

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

Please consider logging the exception before throwing them.

pom.xml Show resolved Hide resolved
Copy link
Owner

@ashwanthkumar ashwanthkumar left a comment

Choose a reason for hiding this comment

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

@Prsna23 LGTM. Can I merge these changes and cut out a beta release?

@Prsna23
Copy link
Contributor Author

Prsna23 commented Sep 8, 2020

Yes please 😃

@ashwanthkumar
Copy link
Owner

We might need some changes on https://github.com/ashwanthkumar/gocd-build-github-pull-requests/blob/master/release.sh. Not a blocker, I can also do these changes as part of merging it to master. Just putting it out there.

@Prsna23
Copy link
Contributor Author

Prsna23 commented Sep 8, 2020

I think I have edited the release.sh file as well. Is there something else that needs to be done?

@ashwanthkumar
Copy link
Owner

Ah, I missed that somehow. Thanks. Merging it now.

@ashwanthkumar ashwanthkumar merged commit 16dc906 into ashwanthkumar:master Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants