├── .gitignore
├── README.md
├── vcs-utils
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── arcbees
│ │ └── vcs
│ │ ├── VcsType.java
│ │ ├── model
│ │ ├── Branch.java
│ │ ├── Commit.java
│ │ ├── Comment.java
│ │ ├── PullRequests.java
│ │ ├── PullRequestTarget.java
│ │ ├── CommitStatus.java
│ │ └── PullRequest.java
│ │ ├── VcsApiFactory.java
│ │ ├── github
│ │ ├── GitHubVcsType.java
│ │ ├── model
│ │ │ ├── GitHubCreateComment.java
│ │ │ ├── GitHubComment.java
│ │ │ ├── GitHubBranch.java
│ │ │ ├── GitHubCommit.java
│ │ │ ├── GitHubPullRequests.java
│ │ │ ├── GitHubPullRequestTarget.java
│ │ │ ├── GitHubCommitStatus.java
│ │ │ └── GitHubPullRequest.java
│ │ ├── GitHubApiFactory.java
│ │ ├── util
│ │ │ └── GitHubPullRequestsTypeAdapter.java
│ │ ├── GitHubApiPaths.java
│ │ └── GitHubApi.java
│ │ ├── util
│ │ ├── HttpClientWrapper.java
│ │ ├── UnexpectedHttpStatusException.java
│ │ ├── CommitStatusTypeAdapter.java
│ │ ├── PolymorphicTypeAdapter.java
│ │ ├── GsonDateTypeAdapter.java
│ │ ├── JsonCustomDataStorage.java
│ │ └── HttpClientWrapperImpl.java
│ │ ├── bitbucket
│ │ ├── BitbucketVcsType.java
│ │ ├── model
│ │ │ ├── BitbucketBranch.java
│ │ │ ├── BitbucketCommit.java
│ │ │ ├── BitbucketComment.java
│ │ │ ├── BitbucketPullRequests.java
│ │ │ ├── BitbucketPullRequestTarget.java
│ │ │ ├── BitbucketCommitStatus.java
│ │ │ └── BitbucketPullRequest.java
│ │ ├── BitbucketApiFactory.java
│ │ ├── BitbucketApiPaths.java
│ │ └── BitbucketApi.java
│ │ ├── stash
│ │ ├── StashVcsType.java
│ │ ├── model
│ │ │ ├── StashBranch.java
│ │ │ ├── StashCommit.java
│ │ │ ├── StashPullRequests.java
│ │ │ ├── StashComment.java
│ │ │ ├── StashPullRequestTarget.java
│ │ │ ├── StashCommitStatus.java
│ │ │ └── StashPullRequest.java
│ │ ├── StashApiFactory.java
│ │ ├── StashApiPaths.java
│ │ └── StashApi.java
│ │ ├── VcsTypes.java
│ │ ├── VcsApiFactories.java
│ │ ├── VcsApi.java
│ │ ├── VcsPropertiesHelper.java
│ │ ├── VcsConstants.java
│ │ ├── VcsPropertiesProcessor.java
│ │ └── AbstractVcsApi.java
│ └── resources
│ ├── META-INF
│ └── build-server-plugin-vcs-utils.xml
│ └── buildServerResources
│ └── vcsSettings.jsp
├── staging
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── META-INF
│ │ │ │ └── build-server-plugin-staging.xml
│ │ │ └── buildServerResources
│ │ │ │ └── staging_deploy.jsp
│ │ └── java
│ │ │ └── com
│ │ │ └── arcbees
│ │ │ └── staging
│ │ │ ├── UrlUtils.java
│ │ │ ├── TomcatManagerFactory.java
│ │ │ ├── TomcatManagerFactoryImpl.java
│ │ │ ├── Constants.java
│ │ │ ├── StagingPropertiesHelper.java
│ │ │ ├── TomcatStagingDeploy.java
│ │ │ ├── TomcatStagingPropertiesProcessor.java
│ │ │ ├── TomcatStagingFeature.java
│ │ │ └── StagingBuildListener.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── arcbees
│ │ └── vcs
│ │ └── util
│ │ └── GsonDateTypeAdapterTest.java
├── teamcity-plugin.xml
├── plugin-assembly.xml
└── pom.xml
├── pullrequests
├── teamcity-plugin.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── arcbees
│ │ │ │ ├── pullrequest
│ │ │ │ ├── BuildStatus.java
│ │ │ │ ├── Constants.java
│ │ │ │ ├── PullRequestPropertiesHelper.java
│ │ │ │ ├── PullRequestBuild.java
│ │ │ │ ├── PullRequestChainParser.java
│ │ │ │ ├── PullRequestsFeature.java
│ │ │ │ └── PullRequestsBuildListener.java
│ │ │ │ └── feature
│ │ │ │ ├── BuildCommitFeature.java
│ │ │ │ ├── BuildCommitBuildListener.java
│ │ │ │ └── BuildCommitStatusHandler.java
│ │ └── resources
│ │ │ ├── META-INF
│ │ │ └── build-server-plugin-pullrequests.xml
│ │ │ └── buildServerResources
│ │ │ ├── feature.jsp
│ │ │ └── pullrequests.jsp
│ └── test
│ │ └── java
│ │ └── com
│ │ └── arcbees
│ │ ├── pullrequest
│ │ └── PullRequestChainParserTest.java
│ │ └── vcs
│ │ └── bitbucket
│ │ └── PullRequestStatusHandlerTest.java
├── plugin-assembly.xml
└── pom.xml
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea*
3 | **/target/*
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | teamcity-plugins
2 | ================
3 |
4 | ##Thanks to
5 | [](http://arcbees.com)
6 |
7 | [](https://www.atlassian.com/)
8 |
9 | [](http://www.jetbrains.com/idea/index.html)
10 |
--------------------------------------------------------------------------------
/vcs-utils/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.arcbees.teamcity
9 | plugins
10 | 1.0-SNAPSHOT
11 |
12 |
13 | vcs-utils
14 | 1.0-SNAPSHOT
15 |
16 |
--------------------------------------------------------------------------------
/staging/src/main/resources/META-INF/build-server-plugin-staging.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/pullrequests/teamcity-plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | PullRequestTrigger
6 | Pull Request Trigger
7 | @Version@
8 |
9 |
10 | maxime.meriouma@arcbees.com
11 |
12 | ArcBees
13 | http://www.arcbees.com
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/staging/teamcity-plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | Tomcat7Staging
6 | Tomcat 7 Deploy to Staging
7 | @Version@
8 |
9 |
10 | maxime.meriouma@arcbees.com
11 |
12 | ArcBees
13 | http://www.arcbees.com
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | public interface VcsType {
20 | String getName();
21 | }
22 |
--------------------------------------------------------------------------------
/pullrequests/src/main/java/com/arcbees/pullrequest/BuildStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.pullrequest;
18 |
19 | public enum BuildStatus {
20 | STARTING,
21 | INTERRUPTED,
22 | FINISHED
23 | }
24 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/model/Branch.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.model;
18 |
19 | public interface Branch {
20 | String getName();
21 |
22 | void setName(String name);
23 | }
24 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/model/Commit.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.model;
18 |
19 | public interface Commit {
20 | String getHash();
21 |
22 | void setHash(String hash);
23 | }
24 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/model/Comment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.model;
18 |
19 | public interface Comment {
20 | Long getCommentId();
21 |
22 | void setCommentId(Long commentId);
23 | }
24 |
--------------------------------------------------------------------------------
/pullrequests/src/main/resources/META-INF/build-server-plugin-pullrequests.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsApiFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | public interface VcsApiFactory {
20 | VcsApi create(VcsPropertiesHelper vcsPropertiesHelper);
21 |
22 | boolean handles(VcsType vcsType);
23 | }
24 |
--------------------------------------------------------------------------------
/staging/plugin-assembly.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | plugin-assembly
6 | false
7 |
8 | zip
9 |
10 |
11 |
12 | target/teamcity-plugin.xml
13 | /
14 |
15 |
16 |
17 |
18 | true
19 | server
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/pullrequests/plugin-assembly.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | plugin-assembly
6 | false
7 |
8 | zip
9 |
10 |
11 |
12 | target/teamcity-plugin.xml
13 | /
14 |
15 |
16 |
17 |
18 | true
19 | server
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/model/PullRequests.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.model;
18 |
19 | import java.util.List;
20 |
21 | public interface PullRequests {
22 | List extends PullRequest> getPullRequests();
23 |
24 | void setPullRequests(List pullRequests);
25 | }
26 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/model/PullRequestTarget.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.model;
18 |
19 | public interface PullRequestTarget {
20 | Commit getCommit();
21 |
22 | void setCommit(C commit);
23 |
24 | Branch getBranch();
25 |
26 | void setBranch(B branch);
27 | }
28 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/resources/META-INF/build-server-plugin-vcs-utils.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/GitHubVcsType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github;
18 |
19 | import com.arcbees.vcs.VcsType;
20 |
21 | public class GitHubVcsType implements VcsType {
22 | private static final String GITHUB = "github";
23 |
24 | @Override
25 | public String getName() {
26 | return GITHUB;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/util/HttpClientWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.util;
18 |
19 | import java.io.IOException;
20 |
21 | import org.apache.http.HttpResponse;
22 | import org.apache.http.client.methods.HttpUriRequest;
23 |
24 | public interface HttpClientWrapper {
25 | HttpResponse execute(HttpUriRequest request) throws IOException;
26 | }
27 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/UrlUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | import java.net.URL;
20 |
21 | public class UrlUtils {
22 | public static String extractBaseUrl(URL url) {
23 | String port = url.getPort() > 0 ? ":" + url.getPort() : "";
24 |
25 | return url.getProtocol() + "://" + url.getHost() + port;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/BitbucketVcsType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket;
18 |
19 | import com.arcbees.vcs.VcsType;
20 |
21 | public class BitbucketVcsType implements VcsType {
22 | private static final String BITBUCKET = "bitbucket";
23 |
24 | @Override
25 | public String getName() {
26 | return BITBUCKET;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/model/CommitStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.model;
18 |
19 | public enum CommitStatus {
20 | ERROR,
21 | FAILURE,
22 | PENDING,
23 | SUCCESS;
24 |
25 | private final String statusCode;
26 |
27 | CommitStatus() {
28 | this.statusCode = name().toLowerCase();
29 | }
30 |
31 | public String getStatusCode() {
32 | return statusCode;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/TomcatManagerFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | import java.net.MalformedURLException;
20 | import java.net.URISyntaxException;
21 |
22 | import org.apache.tomcat.maven.common.deployer.TomcatManager;
23 |
24 | public interface TomcatManagerFactory {
25 | TomcatManager create(StagingPropertiesHelper stagingPropertiesHelper)
26 | throws URISyntaxException, MalformedURLException;
27 | }
28 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/model/GitHubCreateComment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.model;
18 |
19 | public class GitHubCreateComment {
20 | private String body;
21 |
22 | public GitHubCreateComment(String body) {
23 | this.body = body;
24 | }
25 |
26 | public String getBody() {
27 | return body;
28 | }
29 |
30 | public void setBody(String body) {
31 | this.body = body;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/model/BitbucketBranch.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket.model;
18 |
19 | import com.arcbees.vcs.model.Branch;
20 |
21 | public class BitbucketBranch implements Branch {
22 | private String name;
23 |
24 | @Override
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | @Override
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/model/BitbucketCommit.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket.model;
18 |
19 | import com.arcbees.vcs.model.Commit;
20 |
21 | public class BitbucketCommit implements Commit {
22 | private String hash;
23 |
24 | @Override
25 | public String getHash() {
26 | return hash;
27 | }
28 |
29 | @Override
30 | public void setHash(String hash) {
31 | this.hash = hash;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/StashVcsType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * This file is part of Stash TeamCity plugin.
5 | *
6 | * Stash TeamCity plugin is free software: you can redistribute it and/or modify it under the terms of the GNU
7 | * General Public License as published by the Free Software Foundation, either version 3 of the License,
8 | * or (at your option) any later version.
9 | *
10 | * Stash TeamCity plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | * for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with Stash TeamCity plugin. If not,
15 | * see http://www.gnu.org/licenses/.
16 | */
17 |
18 | package com.arcbees.vcs.stash;
19 |
20 | import com.arcbees.vcs.VcsType;
21 |
22 | public class StashVcsType implements VcsType {
23 | private static final String STASH = "stash";
24 |
25 | @Override
26 | public String getName() {
27 | return STASH;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/util/UnexpectedHttpStatusException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.util;
18 |
19 | import java.io.IOException;
20 |
21 | public class UnexpectedHttpStatusException extends IOException {
22 | private final int statusCode;
23 |
24 | public UnexpectedHttpStatusException(int statusCode, String message) {
25 | super(message);
26 | this.statusCode = statusCode;
27 | }
28 |
29 | public int getStatusCode() {
30 | return statusCode;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/model/GitHubComment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.model;
18 |
19 | import com.arcbees.vcs.model.Comment;
20 | import com.google.gson.annotations.SerializedName;
21 |
22 | public class GitHubComment implements Comment {
23 | @SerializedName("id")
24 | private Long commentId;
25 |
26 | @Override
27 | public Long getCommentId() {
28 | return commentId;
29 | }
30 |
31 | @Override
32 | public void setCommentId(Long commentId) {
33 | this.commentId = commentId;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/model/BitbucketComment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket.model;
18 |
19 | import com.arcbees.vcs.model.Comment;
20 | import com.google.gson.annotations.SerializedName;
21 |
22 | public class BitbucketComment implements Comment {
23 | @SerializedName("comment_id")
24 | private Long commentId;
25 |
26 | @Override
27 | public Long getCommentId() {
28 | return commentId;
29 | }
30 |
31 | @Override
32 | public void setCommentId(Long commentId) {
33 | this.commentId = commentId;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/model/GitHubBranch.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.model;
18 |
19 | import com.arcbees.vcs.model.Branch;
20 |
21 | public class GitHubBranch implements Branch {
22 | private String name;
23 |
24 | public GitHubBranch() {
25 | }
26 |
27 | public GitHubBranch(String name) {
28 | this.name = name;
29 | }
30 |
31 | @Override
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | @Override
37 | public void setName(String name) {
38 | this.name = name;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/model/GitHubCommit.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.model;
18 |
19 | import com.arcbees.vcs.model.Commit;
20 |
21 | public class GitHubCommit implements Commit {
22 | private String hash;
23 |
24 | public GitHubCommit() {
25 | }
26 |
27 | public GitHubCommit(String hash) {
28 | this.hash = hash;
29 | }
30 |
31 | @Override
32 | public String getHash() {
33 | return hash;
34 | }
35 |
36 | @Override
37 | public void setHash(String hash) {
38 | this.hash = hash;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/pullrequests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.arcbees.teamcity
9 | plugins
10 | 1.0-SNAPSHOT
11 |
12 |
13 | pullrequests
14 | 1.0-SNAPSHOT
15 |
16 |
17 |
18 | com.arcbees.teamcity
19 | vcs-utils
20 | ${project.version}
21 |
22 |
23 |
24 |
25 |
26 |
27 | com.google.code.maven-replacer-plugin
28 | replacer
29 |
30 |
31 | maven-assembly-plugin
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsTypes.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | import java.util.List;
20 |
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.stereotype.Component;
23 |
24 | @Component
25 | public class VcsTypes {
26 | @Autowired
27 | private List vcsTypes;
28 |
29 | public VcsType getVcsType(String vcsType) {
30 | for (VcsType type : vcsTypes) {
31 | if (type.getName().equals(vcsType)) {
32 | return type;
33 | }
34 | }
35 |
36 | return null;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/pullrequests/src/main/resources/buildServerResources/feature.jsp:
--------------------------------------------------------------------------------
1 | <%@ include file="/include.jsp" %>
2 | <%@ include file="/include-internal.jsp" %>
3 |
4 |
5 |
6 |
32 |
33 | <%@ include file="vcsSettings.jsp" %>
34 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/util/CommitStatusTypeAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.util;
18 |
19 | import java.lang.reflect.Type;
20 |
21 | import com.arcbees.vcs.model.CommitStatus;
22 | import com.google.gson.JsonElement;
23 | import com.google.gson.JsonPrimitive;
24 | import com.google.gson.JsonSerializationContext;
25 | import com.google.gson.JsonSerializer;
26 |
27 | public class CommitStatusTypeAdapter implements JsonSerializer {
28 | @Override
29 | public JsonElement serialize(CommitStatus src, Type typeOfSrc, JsonSerializationContext context) {
30 | return new JsonPrimitive(src.getStatusCode());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/model/GitHubPullRequests.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.model;
18 |
19 | import java.util.List;
20 |
21 | import com.arcbees.vcs.model.PullRequest;
22 | import com.arcbees.vcs.model.PullRequests;
23 |
24 | public class GitHubPullRequests implements PullRequests {
25 | private List pullRequests;
26 |
27 | @Override
28 | public List extends PullRequest> getPullRequests() {
29 | return pullRequests;
30 | }
31 |
32 | @Override
33 | public void setPullRequests(List pullRequests) {
34 | this.pullRequests = pullRequests;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/model/StashBranch.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * This file is part of Stash TeamCity plugin.
5 | *
6 | * Stash TeamCity plugin is free software: you can redistribute it and/or modify it under the terms of the GNU
7 | * General Public License as published by the Free Software Foundation, either version 3 of the License,
8 | * or (at your option) any later version.
9 | *
10 | * Stash TeamCity plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | * for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with Stash TeamCity plugin. If not,
15 | * see http://www.gnu.org/licenses/.
16 | */
17 |
18 | package com.arcbees.vcs.stash.model;
19 |
20 | import com.arcbees.vcs.model.Branch;
21 |
22 | public class StashBranch implements Branch {
23 | private String name;
24 |
25 | public StashBranch() {
26 | }
27 |
28 | public StashBranch(String name) {
29 | this.name = name;
30 | }
31 |
32 | @Override
33 | public String getName() {
34 | return name;
35 | }
36 |
37 | @Override
38 | public void setName(String name) {
39 | this.name = name;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/model/StashCommit.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * This file is part of Stash TeamCity plugin.
5 | *
6 | * Stash TeamCity plugin is free software: you can redistribute it and/or modify it under the terms of the GNU
7 | * General Public License as published by the Free Software Foundation, either version 3 of the License,
8 | * or (at your option) any later version.
9 | *
10 | * Stash TeamCity plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | * for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with Stash TeamCity plugin. If not,
15 | * see http://www.gnu.org/licenses/.
16 | */
17 |
18 | package com.arcbees.vcs.stash.model;
19 |
20 | import com.arcbees.vcs.model.Commit;
21 |
22 | public class StashCommit implements Commit {
23 | private String hash;
24 |
25 | public StashCommit() {
26 | }
27 |
28 | public StashCommit(String hash) {
29 | this.hash = hash;
30 | }
31 |
32 | @Override
33 | public String getHash() {
34 | return hash;
35 | }
36 |
37 | @Override
38 | public void setHash(String hash) {
39 | this.hash = hash;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/TomcatManagerFactoryImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | import java.net.MalformedURLException;
20 | import java.net.URI;
21 | import java.net.URISyntaxException;
22 | import java.net.URL;
23 |
24 | import org.apache.tomcat.maven.common.deployer.TomcatManager;
25 |
26 | public class TomcatManagerFactoryImpl implements TomcatManagerFactory {
27 | @Override
28 | public TomcatManager create(StagingPropertiesHelper propertiesHelper)
29 | throws URISyntaxException, MalformedURLException {
30 | URI uri = new URI(propertiesHelper.getTomcatUrl());
31 | URL url = uri.toURL();
32 |
33 | return new TomcatManager(url, propertiesHelper.getUserName(), propertiesHelper.getPassword());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/model/BitbucketPullRequests.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket.model;
18 |
19 | import java.util.List;
20 |
21 | import com.arcbees.vcs.model.PullRequest;
22 | import com.arcbees.vcs.model.PullRequests;
23 | import com.google.gson.annotations.SerializedName;
24 |
25 | public class BitbucketPullRequests implements PullRequests {
26 | @SerializedName("values")
27 | private List pullRequests;
28 |
29 | @Override
30 | public List extends PullRequest> getPullRequests() {
31 | return pullRequests;
32 | }
33 |
34 | @Override
35 | public void setPullRequests(List pullRequests) {
36 | this.pullRequests = pullRequests;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/pullrequests/src/main/java/com/arcbees/pullrequest/Constants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.pullrequest;
18 |
19 | public class Constants {
20 | private static final String BUILD_SUCCESS = "BUILD SUCCESS ";
21 | private static final String BUILD_FAILURE = "BUILD FAILURE ";
22 | private static final String BUILD_STARTED = "TeamCity Build Started : ";
23 | private static final String APPROVE_ON_SUCCESS_KEY = "pullrequest_approve";
24 |
25 | public String getBuildSuccess() {
26 | return BUILD_SUCCESS;
27 | }
28 |
29 | public String getBuildFailure() {
30 | return BUILD_FAILURE;
31 | }
32 |
33 | public String getBuildStarted() {
34 | return BUILD_STARTED;
35 | }
36 |
37 | public String getApproveOnSuccessKey() {
38 | return APPROVE_ON_SUCCESS_KEY;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsApiFactories.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | import java.util.List;
20 |
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.stereotype.Component;
23 |
24 | @Component
25 | public class VcsApiFactories {
26 | @Autowired
27 | private List factories;
28 | @Autowired
29 | private VcsTypes vcsTypes;
30 |
31 | public VcsApi create(VcsPropertiesHelper vcsPropertiesHelper) {
32 | VcsType vcsType = vcsTypes.getVcsType(vcsPropertiesHelper.getVcsType());
33 | for (VcsApiFactory factory : factories) {
34 | if (factory.handles(vcsType)) {
35 | return factory.create(vcsPropertiesHelper);
36 | }
37 | }
38 |
39 | return null;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestPropertiesHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.pullrequest;
18 |
19 | import java.util.Map;
20 |
21 | import com.arcbees.vcs.VcsConstants;
22 | import com.arcbees.vcs.VcsPropertiesHelper;
23 |
24 | public class PullRequestPropertiesHelper extends VcsPropertiesHelper {
25 | private final Constants pullRequestConstants;
26 |
27 | public PullRequestPropertiesHelper(Map properties,
28 | VcsConstants vcsConstants,
29 | Constants pullRequestConstants) {
30 | super(properties, vcsConstants);
31 |
32 | this.pullRequestConstants = pullRequestConstants;
33 | }
34 |
35 | public boolean getApproveOnSuccessKey() {
36 | return Boolean.parseBoolean(properties.get(pullRequestConstants.getApproveOnSuccessKey()));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/staging/src/test/java/com/arcbees/vcs/util/GsonDateTypeAdapterTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.util;
18 |
19 | import java.lang.reflect.Type;
20 |
21 | import org.junit.Test;
22 |
23 | import com.google.gson.JsonDeserializationContext;
24 | import com.google.gson.JsonElement;
25 | import com.google.gson.JsonPrimitive;
26 |
27 | import static org.mockito.BDDMockito.given;
28 | import static org.mockito.Mockito.mock;
29 |
30 | public class GsonDateTypeAdapterTest {
31 | @Test
32 | public void deserialize() throws Exception {
33 | JsonElement jsonElement = mock(JsonElement.class);
34 | given(jsonElement.getAsJsonPrimitive()).willReturn(new JsonPrimitive("2015-07-29T17:31:29.962962+00:00"));
35 | GsonDateTypeAdapter typeAdapter = new GsonDateTypeAdapter();
36 |
37 | typeAdapter.deserialize(jsonElement, mock(Type.class), mock(JsonDeserializationContext.class));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/model/BitbucketPullRequestTarget.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket.model;
18 |
19 | import com.arcbees.vcs.model.Branch;
20 | import com.arcbees.vcs.model.Commit;
21 | import com.arcbees.vcs.model.PullRequestTarget;
22 |
23 | public class BitbucketPullRequestTarget implements PullRequestTarget {
24 | private BitbucketCommit commit;
25 | private BitbucketBranch branch;
26 |
27 | @Override
28 | public Commit getCommit() {
29 | return commit;
30 | }
31 |
32 | @Override
33 | public void setCommit(BitbucketCommit commit) {
34 | this.commit = commit;
35 | }
36 |
37 | @Override
38 | public Branch getBranch() {
39 | return branch;
40 | }
41 |
42 | @Override
43 | public void setBranch(BitbucketBranch branch) {
44 | this.branch = branch;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/model/StashPullRequests.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * This file is part of Stash TeamCity plugin.
5 | *
6 | * Stash TeamCity plugin is free software: you can redistribute it and/or modify it under the terms of the GNU
7 | * General Public License as published by the Free Software Foundation, either version 3 of the License,
8 | * or (at your option) any later version.
9 | *
10 | * Stash TeamCity plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | * for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with Stash TeamCity plugin. If not,
15 | * see http://www.gnu.org/licenses/.
16 | */
17 |
18 | package com.arcbees.vcs.stash.model;
19 |
20 | import java.util.List;
21 |
22 | import com.arcbees.vcs.model.PullRequest;
23 | import com.arcbees.vcs.model.PullRequests;
24 | import com.google.gson.annotations.SerializedName;
25 |
26 | public class StashPullRequests implements PullRequests {
27 | @SerializedName("values")
28 | private List pullRequests;
29 |
30 | @Override
31 | public List extends PullRequest> getPullRequests() {
32 | return pullRequests;
33 | }
34 |
35 | @Override
36 | public void setPullRequests(List pullRequests) {
37 | this.pullRequests = pullRequests;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/staging/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.arcbees.teamcity
9 | plugins
10 | 1.0-SNAPSHOT
11 |
12 |
13 | staging
14 | 1.0-SNAPSHOT
15 |
16 |
17 | 2.2
18 |
19 |
20 |
21 |
22 | org.apache.tomcat.maven
23 | common-tomcat-maven-plugin
24 | ${tomcat.maven.version}
25 |
26 |
27 | com.arcbees.teamcity
28 | vcs-utils
29 | ${project.version}
30 |
31 |
32 |
33 |
34 |
35 |
36 | com.google.code.maven-replacer-plugin
37 | replacer
38 |
39 |
40 | maven-assembly-plugin
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/model/PullRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.model;
18 |
19 | import java.util.Date;
20 | import java.util.List;
21 |
22 | public interface PullRequest {
23 | String getStatus();
24 |
25 | void setStatus(String status);
26 |
27 | String getDescription();
28 |
29 | void setDescription(String description);
30 |
31 | String getTitle();
32 |
33 | void setTitle(String title);
34 |
35 | int getId();
36 |
37 | void setId(int id);
38 |
39 | Date getCreatedOn();
40 |
41 | void setCreatedOn(Date createdOn);
42 |
43 | Date getUpdatedOn();
44 |
45 | void setUpdatedOn(Date updatedOn);
46 |
47 | PullRequestTarget getSource();
48 |
49 | void setSource(T source);
50 |
51 | PullRequestTarget getDestination();
52 |
53 | void setDestination(T destination);
54 |
55 | List getBranchChain();
56 |
57 | void setBranchChain(List chain);
58 | }
59 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/Constants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | public class Constants {
20 | private static final String USERNAME_KEY = "staging_username";
21 | private static final String PASSWORD_KEY = jetbrains.buildServer.agent.Constants.SECURE_PROPERTY_PREFIX +
22 | "staging_password";
23 | private static final String TOMCAT_URL = "staging_manager";
24 | private static final String MERGE_BRANCH = "staging_branch";
25 | private static final String BASE_CONTEXT = "staging_context";
26 |
27 | public String getUserNameKey() {
28 | return USERNAME_KEY;
29 | }
30 |
31 | public String getPasswordKey() {
32 | return PASSWORD_KEY;
33 | }
34 |
35 | public String getTomcatMergeBranch() {
36 | return MERGE_BRANCH;
37 | }
38 |
39 | public String getTomcatUrl() {
40 | return TOMCAT_URL;
41 | }
42 |
43 | public String getBaseContextKey() {
44 | return BASE_CONTEXT;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/StagingPropertiesHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | import java.util.Map;
20 |
21 | public class StagingPropertiesHelper {
22 | private final Map properties;
23 | private final Constants constants;
24 |
25 | public StagingPropertiesHelper(Map properties,
26 | Constants constants) {
27 | this.properties = properties;
28 | this.constants = constants;
29 | }
30 |
31 | public String getTomcatUrl() {
32 | return properties.get(constants.getTomcatUrl());
33 | }
34 |
35 | public String getMergeBranch() {
36 | return properties.get(constants.getTomcatMergeBranch());
37 | }
38 |
39 | public String getUserName() {
40 | return properties.get(constants.getUserNameKey());
41 | }
42 |
43 | public String getPassword() {
44 | return properties.get(constants.getPasswordKey());
45 | }
46 |
47 | public String getBaseContext() {
48 | return properties.get(constants.getBaseContextKey());
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/model/StashComment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * This file is part of Stash TeamCity plugin.
5 | *
6 | * Stash TeamCity plugin is free software: you can redistribute it and/or modify it under the terms of the GNU
7 | * General Public License as published by the Free Software Foundation, either version 3 of the License,
8 | * or (at your option) any later version.
9 | *
10 | * Stash TeamCity plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | * for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with Stash TeamCity plugin. If not,
15 | * see http://www.gnu.org/licenses/.
16 | */
17 |
18 | package com.arcbees.vcs.stash.model;
19 |
20 | import com.arcbees.vcs.model.Comment;
21 |
22 | public class StashComment implements Comment {
23 | private Long id;
24 | private String text;
25 | private String version;
26 |
27 | public StashComment() {
28 | }
29 |
30 | public StashComment(String text) {
31 | this.text = text;
32 | }
33 |
34 | @Override
35 | public Long getCommentId() {
36 | return id;
37 | }
38 |
39 | @Override
40 | public void setCommentId(Long commentId) {
41 | this.id = commentId;
42 | }
43 |
44 | public String getText() {
45 | return text;
46 | }
47 |
48 | public void setText(String text) {
49 | this.text = text;
50 | }
51 |
52 | public String getVersion() {
53 | return version;
54 | }
55 |
56 | public void setVersion(String version) {
57 | this.version = version;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/model/GitHubPullRequestTarget.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.model;
18 |
19 | import com.arcbees.vcs.model.Branch;
20 | import com.arcbees.vcs.model.Commit;
21 | import com.arcbees.vcs.model.PullRequestTarget;
22 |
23 | public class GitHubPullRequestTarget implements PullRequestTarget {
24 | private GitHubCommit commit;
25 | private GitHubBranch branch;
26 |
27 | // For serialization
28 | private String sha;
29 | private String ref;
30 |
31 | @Override
32 | public Commit getCommit() {
33 | if (commit == null) {
34 | setCommit(new GitHubCommit(sha));
35 | }
36 | return commit;
37 | }
38 |
39 | @Override
40 | public void setCommit(GitHubCommit commit) {
41 | this.commit = commit;
42 | }
43 |
44 | @Override
45 | public Branch getBranch() {
46 | if (branch == null) {
47 | setBranch(new GitHubBranch(ref));
48 | }
49 | return branch;
50 | }
51 |
52 | @Override
53 | public void setBranch(GitHubBranch branch) {
54 | this.branch = branch;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestBuild.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.pullrequest;
18 |
19 | import com.arcbees.vcs.model.Comment;
20 | import com.arcbees.vcs.model.Commit;
21 | import com.arcbees.vcs.model.PullRequest;
22 | import com.arcbees.vcs.model.PullRequestTarget;
23 |
24 | import jetbrains.buildServer.messages.Status;
25 |
26 | public class PullRequestBuild {
27 | private final PullRequest pullRequest;
28 | private final Status lastStatus;
29 | private final Comment lastComment;
30 |
31 | public PullRequestBuild(PullRequest pullRequest, Status lastStatus, Comment lastComment) {
32 | this.pullRequest = pullRequest;
33 | this.lastStatus = lastStatus;
34 | this.lastComment = lastComment;
35 | }
36 |
37 | public PullRequest getPullRequest() {
38 | return pullRequest;
39 | }
40 |
41 | public Status getLastStatus() {
42 | return lastStatus;
43 | }
44 |
45 | public String getLastCommitHash() {
46 | PullRequestTarget source = pullRequest.getSource();
47 | Commit commit = source.getCommit();
48 |
49 | return commit.getHash();
50 | }
51 |
52 | public Comment getLastComment() {
53 | return lastComment;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsApi.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | import java.io.IOException;
20 |
21 | import com.arcbees.vcs.model.Comment;
22 | import com.arcbees.vcs.model.CommitStatus;
23 | import com.arcbees.vcs.model.PullRequest;
24 | import com.arcbees.vcs.model.PullRequests;
25 |
26 | import jetbrains.buildServer.serverSide.SRunningBuild;
27 |
28 | public interface VcsApi {
29 | PullRequests getOpenedPullRequests() throws IOException;
30 |
31 | PullRequests getMergedPullRequests() throws IOException;
32 |
33 | Comment postComment(Integer pullRequestId,
34 | String comment) throws IOException;
35 |
36 | PullRequest getPullRequestForBranch(String branchName) throws IOException;
37 |
38 | void deleteComment(Integer pullRequestId, Long commentId) throws IOException;
39 |
40 | void updateStatus(String commitHash, String message, CommitStatus status, String targetUrl, SRunningBuild build)
41 | throws IOException, UnsupportedOperationException;
42 |
43 | void approvePullRequest(Integer pullRequestId) throws IOException, UnsupportedOperationException;
44 |
45 | void deletePullRequestApproval(Integer pullRequestId) throws IOException, UnsupportedOperationException;
46 | }
47 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/GitHubApiFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github;
18 |
19 | import com.arcbees.vcs.VcsApi;
20 | import com.arcbees.vcs.VcsApiFactory;
21 | import com.arcbees.vcs.VcsPropertiesHelper;
22 | import com.arcbees.vcs.VcsType;
23 | import com.arcbees.vcs.util.HttpClientWrapper;
24 |
25 | public class GitHubApiFactory implements VcsApiFactory {
26 | private final HttpClientWrapper httpClient;
27 | private final GitHubVcsType gitHubVcsType;
28 |
29 | public GitHubApiFactory(HttpClientWrapper httpClient,
30 | GitHubVcsType gitHubVcsType) {
31 | this.httpClient = httpClient;
32 | this.gitHubVcsType = gitHubVcsType;
33 | }
34 |
35 | @Override
36 | public boolean handles(VcsType vcsType) {
37 | return vcsType.equals(gitHubVcsType);
38 | }
39 |
40 | @Override
41 | public VcsApi create(VcsPropertiesHelper vcsPropertiesHelper) {
42 | return new GitHubApi(httpClient, new GitHubApiPaths(vcsPropertiesHelper.getServerUrl()),
43 | vcsPropertiesHelper.getUserName(),
44 | vcsPropertiesHelper.getPassword(),
45 | vcsPropertiesHelper.getRepositoryOwner(),
46 | vcsPropertiesHelper.getRepositoryName());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/model/StashPullRequestTarget.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * This file is part of Stash TeamCity plugin.
5 | *
6 | * Stash TeamCity plugin is free software: you can redistribute it and/or modify it under the terms of the GNU
7 | * General Public License as published by the Free Software Foundation, either version 3 of the License,
8 | * or (at your option) any later version.
9 | *
10 | * Stash TeamCity plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | * for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with Stash TeamCity plugin. If not,
15 | * see http://www.gnu.org/licenses/.
16 | */
17 |
18 | package com.arcbees.vcs.stash.model;
19 |
20 | import com.arcbees.vcs.model.Branch;
21 | import com.arcbees.vcs.model.Commit;
22 | import com.arcbees.vcs.model.PullRequestTarget;
23 |
24 | public class StashPullRequestTarget implements PullRequestTarget {
25 | private StashCommit commit;
26 | private StashBranch branch;
27 | private String latestChangeset;
28 | private String displayId;
29 |
30 | @Override
31 | public Commit getCommit() {
32 | if (commit == null) {
33 | setCommit(new StashCommit(latestChangeset));
34 | }
35 | return commit;
36 | }
37 |
38 | @Override
39 | public void setCommit(StashCommit commit) {
40 | this.commit = commit;
41 | }
42 |
43 | @Override
44 | public Branch getBranch() {
45 | if (branch == null) {
46 | setBranch(new StashBranch(displayId));
47 | }
48 | return branch;
49 | }
50 |
51 | @Override
52 | public void setBranch(StashBranch branch) {
53 | this.branch = branch;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/BitbucketApiFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket;
18 |
19 | import com.arcbees.vcs.VcsApi;
20 | import com.arcbees.vcs.VcsApiFactory;
21 | import com.arcbees.vcs.VcsPropertiesHelper;
22 | import com.arcbees.vcs.VcsType;
23 | import com.arcbees.vcs.util.HttpClientWrapper;
24 |
25 | public class BitbucketApiFactory implements VcsApiFactory {
26 | private final HttpClientWrapper httpClient;
27 | private final BitbucketVcsType bitbucketVcsType;
28 |
29 | public BitbucketApiFactory(HttpClientWrapper httpClient,
30 | BitbucketVcsType bitbucketVcsType) {
31 | this.httpClient = httpClient;
32 | this.bitbucketVcsType = bitbucketVcsType;
33 | }
34 |
35 | @Override
36 | public boolean handles(VcsType vcsType) {
37 | return vcsType.equals(bitbucketVcsType);
38 | }
39 |
40 | @Override
41 | public VcsApi create(VcsPropertiesHelper vcsPropertiesHelper) {
42 | return new BitbucketApi(httpClient, new BitbucketApiPaths(vcsPropertiesHelper.getServerUrl()),
43 | vcsPropertiesHelper.getUserName(),
44 | vcsPropertiesHelper.getPassword(),
45 | vcsPropertiesHelper.getRepositoryOwner(),
46 | vcsPropertiesHelper.getRepositoryName());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsPropertiesHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | import java.util.Map;
20 |
21 | public class VcsPropertiesHelper {
22 | protected final Map properties;
23 |
24 | private final VcsConstants vcsConstants;
25 |
26 | public VcsPropertiesHelper(Map properties,
27 | VcsConstants vcsConstants) {
28 | this.properties = properties;
29 | this.vcsConstants = vcsConstants;
30 | }
31 |
32 | public String getRepositoryName() {
33 | return properties.get(vcsConstants.getRepositoryNameKey());
34 | }
35 |
36 | public String getRepositoryOwner() {
37 | return properties.get(vcsConstants.getRepositoryOwnerKey());
38 | }
39 |
40 | public String getPassword() {
41 | return properties.get(vcsConstants.getPasswordKey());
42 | }
43 |
44 | public String getUserName() {
45 | return properties.get(vcsConstants.getUserNameKey());
46 | }
47 |
48 | public String getVcsType() {
49 | return properties.get(vcsConstants.getVcsType());
50 | }
51 |
52 | public String getServerUrl() {
53 | return properties.get(vcsConstants.getServerUrl());
54 | }
55 |
56 | public String getBaseBranch() {
57 | return properties.get(vcsConstants.getBaseBranchKey());
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/StashApiFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * This file is part of Stash TeamCity plugin.
5 | *
6 | * Stash TeamCity plugin is free software: you can redistribute it and/or modify it under the terms of the GNU
7 | * General Public License as published by the Free Software Foundation, either version 3 of the License,
8 | * or (at your option) any later version.
9 | *
10 | * Stash TeamCity plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 | * for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License along with Stash TeamCity plugin. If not,
15 | * see http://www.gnu.org/licenses/.
16 | */
17 |
18 | package com.arcbees.vcs.stash;
19 |
20 | import com.arcbees.vcs.VcsApi;
21 | import com.arcbees.vcs.VcsApiFactory;
22 | import com.arcbees.vcs.VcsPropertiesHelper;
23 | import com.arcbees.vcs.VcsType;
24 | import com.arcbees.vcs.util.HttpClientWrapper;
25 |
26 | public class StashApiFactory implements VcsApiFactory {
27 | private final HttpClientWrapper httpClient;
28 | private final StashVcsType stashVcsType;
29 |
30 | public StashApiFactory(HttpClientWrapper httpClient,
31 | StashVcsType stashVcsType) {
32 | this.httpClient = httpClient;
33 | this.stashVcsType = stashVcsType;
34 | }
35 |
36 | @Override
37 | public boolean handles(VcsType vcsType) {
38 | return vcsType.equals(stashVcsType);
39 | }
40 |
41 | @Override
42 | public VcsApi create(VcsPropertiesHelper vcsPropertiesHelper) {
43 | return new StashApi(httpClient, new StashApiPaths(vcsPropertiesHelper.getServerUrl()),
44 | vcsPropertiesHelper.getUserName(),
45 | vcsPropertiesHelper.getPassword(),
46 | vcsPropertiesHelper.getRepositoryOwner(),
47 | vcsPropertiesHelper.getRepositoryName());
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/pullrequests/src/main/resources/buildServerResources/pullrequests.jsp:
--------------------------------------------------------------------------------
1 | <%@ include file="/include.jsp" %>
2 | <%@ include file="/include-internal.jsp" %>
3 |
4 |
5 |
6 |
7 |
33 |
34 | <%@ include file="vcsSettings.jsp" %>
35 |
36 |
Base branch:
37 |
38 |
39 |
40 | Base VCS branch
41 |
42 |
43 |
44 |
45 |
Approve on success:
46 |
47 |
48 |
49 | User should approve request on build success
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | import static jetbrains.buildServer.agent.Constants.SECURE_PROPERTY_PREFIX;
20 |
21 | public class VcsConstants {
22 | private static final String USERNAME_KEY = "vcs_username";
23 | private static final String PASSWORD_KEY = SECURE_PROPERTY_PREFIX + "vcs_password";
24 | private static final String SERVER_URL = "vcs_server";
25 | private static final String REPOSITORY_KEY = "vcs_repo";
26 | private static final String REPOSITORY_OWNER = "vcs_owner";
27 | private static final String PULLREQUEST_KEY = "vcs_pullrequest_";
28 | private static final String VCS_TYPE = "vcs_type";
29 | private static final String BASE_BRANCH_KEY = "base_branch";
30 |
31 | public String getUserNameKey() {
32 | return USERNAME_KEY;
33 | }
34 |
35 | public String getPasswordKey() {
36 | return PASSWORD_KEY;
37 | }
38 |
39 | public String getRepositoryNameKey() {
40 | return REPOSITORY_KEY;
41 | }
42 |
43 | public String getRepositoryOwnerKey() {
44 | return REPOSITORY_OWNER;
45 | }
46 |
47 | public String getServerUrl() {
48 | return SERVER_URL;
49 | }
50 |
51 | public String getPullRequestKey() {
52 | return PULLREQUEST_KEY;
53 | }
54 |
55 | public String getVcsType() {
56 | return VCS_TYPE;
57 | }
58 |
59 | public String getBaseBranchKey() {
60 | return BASE_BRANCH_KEY;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/model/GitHubCommitStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.model;
18 |
19 | import com.arcbees.vcs.model.CommitStatus;
20 | import com.google.gson.annotations.SerializedName;
21 |
22 | public class GitHubCommitStatus {
23 | private CommitStatus state;
24 | @SerializedName("target_url")
25 | private String targetUrl;
26 | private String description;
27 | private String context;
28 |
29 | public GitHubCommitStatus() {
30 | }
31 |
32 | public GitHubCommitStatus(CommitStatus state,
33 | String description,
34 | String targetUrl) {
35 | this.state = state;
36 | this.description = description;
37 | this.targetUrl = targetUrl;
38 | }
39 |
40 | public CommitStatus getState() {
41 | return state;
42 | }
43 |
44 | public void setState(CommitStatus state) {
45 | this.state = state;
46 | }
47 |
48 | public String getTargetUrl() {
49 | return targetUrl;
50 | }
51 |
52 | public void setTargetUrl(String targetUrl) {
53 | this.targetUrl = targetUrl;
54 | }
55 |
56 | public String getDescription() {
57 | return description;
58 | }
59 |
60 | public void setDescription(String description) {
61 | this.description = description;
62 | }
63 |
64 | public String getContext() {
65 | return context;
66 | }
67 |
68 | public void setContext(String context) {
69 | this.context = context;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/github/util/GitHubPullRequestsTypeAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.github.util;
18 |
19 | import java.lang.reflect.Type;
20 | import java.util.List;
21 |
22 | import com.arcbees.vcs.github.model.GitHubPullRequest;
23 | import com.arcbees.vcs.github.model.GitHubPullRequests;
24 | import com.google.common.base.Function;
25 | import com.google.common.collect.FluentIterable;
26 | import com.google.gson.JsonArray;
27 | import com.google.gson.JsonDeserializationContext;
28 | import com.google.gson.JsonDeserializer;
29 | import com.google.gson.JsonElement;
30 | import com.google.gson.JsonParseException;
31 |
32 | public class GitHubPullRequestsTypeAdapter implements JsonDeserializer {
33 | @Override
34 | public GitHubPullRequests deserialize(JsonElement json, Type typeOfT, final JsonDeserializationContext context)
35 | throws JsonParseException {
36 | JsonArray jsonArray = json.getAsJsonArray();
37 |
38 | List pullRequests = FluentIterable.from(jsonArray)
39 | .transform(new Function() {
40 | @Override
41 | public GitHubPullRequest apply(JsonElement input) {
42 | return context.deserialize(input, GitHubPullRequest.class);
43 | }
44 | }).toImmutableList();
45 |
46 | GitHubPullRequests gitHubPullRequests = new GitHubPullRequests();
47 | gitHubPullRequests.setPullRequests(pullRequests);
48 |
49 | return gitHubPullRequests;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/TomcatStagingDeploy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | import com.arcbees.vcs.model.Comment;
20 | import com.arcbees.vcs.model.PullRequest;
21 |
22 | public class TomcatStagingDeploy {
23 | private final PullRequest pullRequest;
24 |
25 | private Comment comment;
26 | private boolean deployed;
27 | private boolean undeployed;
28 | private String webPath;
29 |
30 | public TomcatStagingDeploy(PullRequest pullRequest, boolean deployed) {
31 | this(pullRequest, deployed, false);
32 | }
33 |
34 | public TomcatStagingDeploy(PullRequest pullRequest, boolean deployed, boolean undeployed) {
35 | this.pullRequest = pullRequest;
36 | this.deployed = deployed;
37 | this.undeployed = undeployed;
38 | }
39 |
40 | public PullRequest getPullRequest() {
41 | return pullRequest;
42 | }
43 |
44 | public boolean isUndeployed() {
45 | return undeployed;
46 | }
47 |
48 | public boolean isDeployed() {
49 | return deployed;
50 | }
51 |
52 | public void setDeployed(boolean deployed) {
53 | this.deployed = deployed;
54 | }
55 |
56 | public void setUndeployed(boolean undeployed) {
57 | this.undeployed = undeployed;
58 | }
59 |
60 | public Comment getComment() {
61 | return comment;
62 | }
63 |
64 | public void setComment(Comment comment) {
65 | this.comment = comment;
66 | }
67 |
68 | public String getWebPath() {
69 | return webPath;
70 | }
71 |
72 | public void setWebPath(String webPath) {
73 | this.webPath = webPath;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestChainParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.pullrequest;
18 |
19 | import java.util.List;
20 | import java.util.Map;
21 |
22 | import com.arcbees.vcs.model.PullRequest;
23 | import com.arcbees.vcs.model.PullRequestTarget;
24 | import com.arcbees.vcs.model.PullRequests;
25 | import com.google.common.collect.Lists;
26 | import com.google.common.collect.Maps;
27 |
28 | public class PullRequestChainParser {
29 | public void parsePullRequestChains(PullRequests extends PullRequest> pullRequests) {
30 | Map pullRequestsMap = Maps.newHashMap();
31 | for (PullRequest pullRequest : pullRequests.getPullRequests()) {
32 | pullRequestsMap.put(pullRequest.getSource().getBranch().getName(), pullRequest);
33 | }
34 |
35 | for (PullRequest pullRequest : pullRequestsMap.values()) {
36 | List chain = Lists.newArrayList();
37 |
38 | PullRequestTarget destination = pullRequest.getDestination();
39 | String branchName = destination.getBranch().getName();
40 | chain.add(branchName);
41 | do {
42 | PullRequest destinationPullRequest = pullRequestsMap.get(branchName);
43 | if (destinationPullRequest != null) {
44 | branchName = destinationPullRequest.getDestination().getBranch().getName();
45 | chain.add(branchName);
46 | } else {
47 | break;
48 | }
49 | } while (pullRequestsMap.containsKey(branchName));
50 |
51 | pullRequest.setBranchChain(chain);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/pullrequests/src/main/java/com/arcbees/feature/BuildCommitFeature.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.feature;
18 |
19 | import org.jetbrains.annotations.NotNull;
20 | import org.jetbrains.annotations.Nullable;
21 |
22 | import com.arcbees.vcs.VcsPropertiesProcessor;
23 |
24 | import jetbrains.buildServer.serverSide.BuildFeature;
25 | import jetbrains.buildServer.serverSide.PropertiesProcessor;
26 | import jetbrains.buildServer.web.openapi.PluginDescriptor;
27 |
28 | public class BuildCommitFeature extends BuildFeature {
29 | public static final String NAME = "teamcity.build.commit.status";
30 |
31 | private static final String DISPLAY_NAME = "Report commit build status";
32 | private static final String EDIT_URL = "feature.jsp";
33 |
34 | private final VcsPropertiesProcessor propertiesProcessor;
35 | private final PluginDescriptor pluginDescriptor;
36 |
37 | public BuildCommitFeature(
38 | VcsPropertiesProcessor propertiesProcessor,
39 | PluginDescriptor pluginDescriptor) {
40 | this.propertiesProcessor = propertiesProcessor;
41 | this.pluginDescriptor = pluginDescriptor;
42 | }
43 |
44 | @NotNull
45 | @Override
46 | public String getType() {
47 | return NAME;
48 | }
49 |
50 | @NotNull
51 | @Override
52 | public String getDisplayName() {
53 | return DISPLAY_NAME;
54 | }
55 |
56 | @Nullable
57 | @Override
58 | public String getEditParametersUrl() {
59 | return pluginDescriptor.getPluginResourcesPath(EDIT_URL);
60 | }
61 |
62 | @Nullable
63 | @Override
64 | public PropertiesProcessor getParametersProcessor() {
65 | return propertiesProcessor;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/util/PolymorphicTypeAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.util;
18 |
19 | import java.lang.reflect.Type;
20 |
21 | import com.google.gson.JsonDeserializationContext;
22 | import com.google.gson.JsonDeserializer;
23 | import com.google.gson.JsonElement;
24 | import com.google.gson.JsonObject;
25 | import com.google.gson.JsonParseException;
26 | import com.google.gson.JsonPrimitive;
27 | import com.google.gson.JsonSerializationContext;
28 | import com.google.gson.JsonSerializer;
29 |
30 | public class PolymorphicTypeAdapter implements JsonSerializer, JsonDeserializer {
31 | private static final String CLASSNAME = "@class";
32 | private static final String VALUE = "@value";
33 |
34 | @Override
35 | public T deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
36 | JsonObject jsonObject = json.getAsJsonObject();
37 | JsonPrimitive jsonPrimitive = (JsonPrimitive) jsonObject.get(CLASSNAME);
38 | String className = jsonPrimitive.getAsString();
39 |
40 | Class> clazz;
41 | try {
42 | clazz = Class.forName(className);
43 | } catch (ClassNotFoundException e) {
44 | throw new JsonParseException(e.getMessage());
45 | }
46 |
47 | return context.deserialize(jsonObject.get(VALUE), clazz);
48 | }
49 |
50 | @Override
51 | public JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context) {
52 | JsonObject retValue = new JsonObject();
53 |
54 | String className = src.getClass().getCanonicalName();
55 | retValue.addProperty(CLASSNAME, className);
56 |
57 | JsonElement jsonElement = context.serialize(src);
58 | retValue.add(VALUE, jsonElement);
59 |
60 | return retValue;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/VcsPropertiesProcessor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs;
18 |
19 | import java.util.ArrayList;
20 | import java.util.Collection;
21 | import java.util.Map;
22 |
23 | import com.google.common.base.Strings;
24 |
25 | import jetbrains.buildServer.serverSide.InvalidProperty;
26 | import jetbrains.buildServer.serverSide.PropertiesProcessor;
27 |
28 | public class VcsPropertiesProcessor implements PropertiesProcessor {
29 | private final VcsConstants vcsConstants;
30 |
31 | public VcsPropertiesProcessor(VcsConstants vcsConstants) {
32 | this.vcsConstants = vcsConstants;
33 | }
34 |
35 | @Override
36 | public Collection process(Map properties) {
37 | Collection result = new ArrayList();
38 | if (properties == null) return result;
39 |
40 | checkNotEmpty(properties, vcsConstants.getUserNameKey(), "Username must be specified", result);
41 | checkNotEmpty(properties, vcsConstants.getPasswordKey(), "Password must be specified", result);
42 | checkNotEmpty(properties, vcsConstants.getRepositoryOwnerKey(), "Repository owner must be specified", result);
43 | checkNotEmpty(properties, vcsConstants.getRepositoryNameKey(), "Repository name must be specified", result);
44 |
45 | return result;
46 | }
47 |
48 | private void checkNotEmpty(Map properties,
49 | String key,
50 | String message,
51 | Collection result) {
52 | if (isEmptyOrSpaces(properties.get(key))) {
53 | result.add(new InvalidProperty(key, message));
54 | }
55 | }
56 |
57 | private boolean isEmptyOrSpaces(String value) {
58 | return Strings.nullToEmpty(value).trim().isEmpty();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/TomcatStagingPropertiesProcessor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | import java.util.ArrayList;
20 | import java.util.Collection;
21 | import java.util.Map;
22 |
23 | import com.google.common.base.Strings;
24 |
25 | import jetbrains.buildServer.serverSide.InvalidProperty;
26 | import jetbrains.buildServer.serverSide.PropertiesProcessor;
27 |
28 | public class TomcatStagingPropertiesProcessor implements PropertiesProcessor {
29 | private final Constants constants;
30 |
31 | public TomcatStagingPropertiesProcessor(Constants constants) {
32 | this.constants = constants;
33 | }
34 |
35 | @Override
36 | public Collection process(Map properties) {
37 | Collection result = new ArrayList();
38 | if (properties == null) return result;
39 |
40 | checkNotEmpty(properties, constants.getUserNameKey(), "Username must be specified", result);
41 | checkNotEmpty(properties, constants.getPasswordKey(), "Password must be specified", result);
42 | checkNotEmpty(properties, constants.getTomcatUrl(), "Tomcat Manager URL must be specified", result);
43 |
44 | String contextPath = properties.get(constants.getBaseContextKey());
45 | if (!Strings.isNullOrEmpty(contextPath) && !contextPath.startsWith("/")) {
46 | properties.put(constants.getBaseContextKey(), "/" + contextPath);
47 | }
48 |
49 | return result;
50 | }
51 |
52 | private void checkNotEmpty(Map properties,
53 | String key,
54 | String message,
55 | Collection result) {
56 | if (isEmptyOrSpaces(properties.get(key))) {
57 | result.add(new InvalidProperty(key, message));
58 | }
59 | }
60 |
61 | private boolean isEmptyOrSpaces(String value) {
62 | return Strings.nullToEmpty(value).trim().isEmpty();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/util/GsonDateTypeAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.util;
18 |
19 | import java.lang.reflect.Type;
20 | import java.text.DateFormat;
21 | import java.text.ParseException;
22 | import java.text.SimpleDateFormat;
23 | import java.util.Date;
24 | import java.util.List;
25 |
26 | import com.google.common.collect.ImmutableList;
27 | import com.google.gson.JsonDeserializationContext;
28 | import com.google.gson.JsonDeserializer;
29 | import com.google.gson.JsonElement;
30 | import com.google.gson.JsonParseException;
31 |
32 | public class GsonDateTypeAdapter implements JsonDeserializer {
33 | private static final DateFormat DATE_TIME_FORMAT = DateFormat.getDateTimeInstance();
34 | private static final DateFormat DATE_TIME_LONG_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
35 | private static final DateFormat DATE_TIME_LONG_FORMAT_ALT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
36 | private static final DateFormat DATE_TIME_LONG_FORMAT_ALT2 = new SimpleDateFormat(
37 | "yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX");
38 | private static final DateFormat CUSTOM_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssXXX");
39 | private static final List dateFormats =
40 | ImmutableList.of(DATE_TIME_LONG_FORMAT_ALT2, DATE_TIME_LONG_FORMAT, DATE_TIME_FORMAT,
41 | CUSTOM_DATE_FORMAT, DATE_TIME_LONG_FORMAT_ALT);
42 |
43 | @Override
44 | public Date deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
45 | String value = json.getAsJsonPrimitive().getAsString();
46 | synchronized (dateFormats) {
47 | for (DateFormat dateFormat : dateFormats) {
48 | try {
49 | return dateFormat.parse(value);
50 | } catch (ParseException e) {
51 | }
52 | }
53 | }
54 |
55 | try {
56 | return new Date(json.getAsJsonPrimitive().getAsLong());
57 | } catch (NumberFormatException e) {
58 | throw new JsonParseException(e);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/pullrequests/src/test/java/com/arcbees/pullrequest/PullRequestChainParserTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.pullrequest;
18 |
19 | import org.junit.Before;
20 | import org.junit.Test;
21 |
22 | import com.arcbees.vcs.bitbucket.model.BitbucketBranch;
23 | import com.arcbees.vcs.bitbucket.model.BitbucketPullRequest;
24 | import com.arcbees.vcs.bitbucket.model.BitbucketPullRequestTarget;
25 | import com.arcbees.vcs.bitbucket.model.BitbucketPullRequests;
26 |
27 | import static java.util.Arrays.asList;
28 |
29 | import static org.junit.Assert.assertEquals;
30 | import static org.junit.Assert.assertTrue;
31 |
32 | public class PullRequestChainParserTest {
33 | private PullRequestChainParser parser;
34 |
35 | @Before
36 | public void setUp() {
37 | parser = new PullRequestChainParser();
38 | }
39 |
40 | @Test
41 | public void parseChain_parseCorrectly() throws Exception {
42 | BitbucketPullRequest firstPr = createPr("a", "master");
43 | BitbucketPullRequest secondPr = createPr("b", "a");
44 | BitbucketPullRequests pullRequests = new BitbucketPullRequests();
45 | pullRequests.setPullRequests(asList(secondPr, firstPr));
46 |
47 | parser.parsePullRequestChains(pullRequests);
48 |
49 | assertEquals(1, firstPr.getBranchChain().size());
50 | assertEquals(2, secondPr.getBranchChain().size());
51 | assertTrue(firstPr.getBranchChain().contains("master"));
52 | assertTrue(secondPr.getBranchChain().containsAll(asList("a", "master")));
53 | }
54 |
55 | private BitbucketPullRequest createPr(String sourceBranch, String targetBranch) {
56 | BitbucketPullRequest pullRequest = new BitbucketPullRequest();
57 | pullRequest.setSource(createPrTarget(sourceBranch));
58 | pullRequest.setDestination(createPrTarget(targetBranch));
59 |
60 | return pullRequest;
61 | }
62 |
63 | private BitbucketPullRequestTarget createPrTarget(String branchName) {
64 | BitbucketPullRequestTarget target = new BitbucketPullRequestTarget();
65 | BitbucketBranch sourceBranch = new BitbucketBranch();
66 | sourceBranch.setName(branchName);
67 | target.setBranch(sourceBranch);
68 |
69 | return target;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/staging/src/main/java/com/arcbees/staging/TomcatStagingFeature.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.staging;
18 |
19 | import org.jetbrains.annotations.NotNull;
20 | import org.jetbrains.annotations.Nullable;
21 |
22 | import jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor;
23 | import jetbrains.buildServer.buildTriggers.BuildTriggerService;
24 | import jetbrains.buildServer.buildTriggers.BuildTriggeringPolicy;
25 | import jetbrains.buildServer.serverSide.PropertiesProcessor;
26 | import jetbrains.buildServer.web.openapi.PluginDescriptor;
27 |
28 | public class TomcatStagingFeature extends BuildTriggerService {
29 | public static final String NAME = "TomcatStaging";
30 |
31 | private static final String DISPLAY_NAME = "Tomcat 7 Deploy and Staging";
32 | private static final String EDIT_URL = "staging_deploy.jsp";
33 |
34 | private final TomcatStagingPropertiesProcessor propertiesProcessor;
35 | private final TomcatStagingTrigger triggeringPolicy;
36 | private final PluginDescriptor pluginDescriptor;
37 |
38 | public TomcatStagingFeature(TomcatStagingTrigger triggeringPolicy,
39 | TomcatStagingPropertiesProcessor propertiesProcessor,
40 | PluginDescriptor pluginDescriptor) {
41 | this.triggeringPolicy = triggeringPolicy;
42 | this.propertiesProcessor = propertiesProcessor;
43 | this.pluginDescriptor = pluginDescriptor;
44 | }
45 |
46 | @NotNull
47 | @Override
48 | public String getName() {
49 | return NAME;
50 | }
51 |
52 | @NotNull
53 | @Override
54 | public String getDisplayName() {
55 | return DISPLAY_NAME;
56 | }
57 |
58 | @NotNull
59 | @Override
60 | public String describeTrigger(@NotNull BuildTriggerDescriptor buildTriggerDescriptor) {
61 | return DISPLAY_NAME;
62 | }
63 |
64 | @NotNull
65 | @Override
66 | public BuildTriggeringPolicy getBuildTriggeringPolicy() {
67 | return triggeringPolicy;
68 | }
69 |
70 | @Nullable
71 | @Override
72 | public String getEditParametersUrl() {
73 | return pluginDescriptor.getPluginResourcesPath(EDIT_URL);
74 | }
75 |
76 | @Nullable
77 | @Override
78 | public PropertiesProcessor getTriggerPropertiesProcessor() {
79 | return propertiesProcessor;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/bitbucket/model/BitbucketCommitStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.bitbucket.model;
18 |
19 | import com.arcbees.vcs.model.CommitStatus;
20 |
21 | public class BitbucketCommitStatus {
22 | public enum State {
23 | INPROGRESS,
24 | SUCCESSFUL,
25 | FAILED;
26 |
27 | public static State fromCommitSatus(CommitStatus status) {
28 | switch (status) {
29 | case ERROR:
30 | case FAILURE:
31 | return FAILED;
32 | case PENDING:
33 | return INPROGRESS;
34 | case SUCCESS:
35 | return SUCCESSFUL;
36 | }
37 |
38 | return FAILED;
39 | }
40 | }
41 |
42 | private State state;
43 | private String url;
44 | private String description;
45 | private String key;
46 | private String name;
47 |
48 | public BitbucketCommitStatus() {
49 | }
50 |
51 | public BitbucketCommitStatus(
52 | CommitStatus status,
53 | String key,
54 | String name,
55 | String description,
56 | String url) {
57 | this.key = key;
58 | this.name = name;
59 | this.state = State.fromCommitSatus(status);
60 | this.description = description;
61 | this.url = url;
62 | }
63 |
64 | public State getState() {
65 | return state;
66 | }
67 |
68 | public void setState(State state) {
69 | this.state = state;
70 | }
71 |
72 | public String getUrl() {
73 | return url;
74 | }
75 |
76 | public void setUrl(String url) {
77 | this.url = url;
78 | }
79 |
80 | public String getDescription() {
81 | return description;
82 | }
83 |
84 | public void setDescription(String description) {
85 | this.description = description;
86 | }
87 |
88 | public String getKey() {
89 | return key;
90 | }
91 |
92 | public void setKey(String key) {
93 | this.key = key;
94 | }
95 |
96 | public String getName() {
97 | return name;
98 | }
99 |
100 | public void setName(String name) {
101 | this.name = name;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestsFeature.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.pullrequest;
18 |
19 | import org.jetbrains.annotations.NotNull;
20 | import org.jetbrains.annotations.Nullable;
21 |
22 | import com.arcbees.vcs.VcsPropertiesProcessor;
23 |
24 | import jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor;
25 | import jetbrains.buildServer.buildTriggers.BuildTriggerService;
26 | import jetbrains.buildServer.buildTriggers.BuildTriggeringPolicy;
27 | import jetbrains.buildServer.serverSide.PropertiesProcessor;
28 | import jetbrains.buildServer.web.openapi.PluginDescriptor;
29 |
30 | public class PullRequestsFeature extends BuildTriggerService {
31 | public static final String NAME = "PullRequests";
32 |
33 | private static final String DISPLAY_NAME = "Pull Requests";
34 | private static final String EDIT_URL = "pullrequests.jsp";
35 |
36 | private final VcsPropertiesProcessor propertiesProcessor;
37 | private final PullRequestsTrigger triggeringPolicy;
38 | private final PluginDescriptor pluginDescriptor;
39 |
40 | public PullRequestsFeature(PullRequestsTrigger triggeringPolicy,
41 | VcsPropertiesProcessor propertiesProcessor,
42 | PluginDescriptor pluginDescriptor) {
43 | this.triggeringPolicy = triggeringPolicy;
44 | this.propertiesProcessor = propertiesProcessor;
45 | this.pluginDescriptor = pluginDescriptor;
46 | }
47 |
48 | @NotNull
49 | @Override
50 | public String getName() {
51 | return NAME;
52 | }
53 |
54 | @NotNull
55 | @Override
56 | public String getDisplayName() {
57 | return DISPLAY_NAME;
58 | }
59 |
60 | @NotNull
61 | @Override
62 | public String describeTrigger(@NotNull BuildTriggerDescriptor buildTriggerDescriptor) {
63 | return DISPLAY_NAME;
64 | }
65 |
66 | @NotNull
67 | @Override
68 | public BuildTriggeringPolicy getBuildTriggeringPolicy() {
69 | return triggeringPolicy;
70 | }
71 |
72 | @Nullable
73 | @Override
74 | public String getEditParametersUrl() {
75 | return pluginDescriptor.getPluginResourcesPath(EDIT_URL);
76 | }
77 |
78 | @Nullable
79 | @Override
80 | public PropertiesProcessor getTriggerPropertiesProcessor() {
81 | return propertiesProcessor;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/stash/model/StashCommitStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.stash.model;
18 |
19 | import com.arcbees.vcs.model.CommitStatus;
20 |
21 | public class StashCommitStatus {
22 | public static enum State {
23 | INPROGRESS,
24 | SUCCESSFUL,
25 | FAILED;
26 |
27 | public static State fromCommitSatus(CommitStatus status) {
28 | switch (status) {
29 | case ERROR:
30 | case FAILURE:
31 | return FAILED;
32 | case PENDING:
33 | return INPROGRESS;
34 | case SUCCESS:
35 | return SUCCESSFUL;
36 | }
37 |
38 | return FAILED;
39 | }
40 | }
41 |
42 | private State state;
43 | private String url;
44 | private String description;
45 | private String key;
46 | private String name;
47 |
48 | public StashCommitStatus() {
49 | }
50 |
51 | public StashCommitStatus(CommitStatus status,
52 | String key,
53 | String name,
54 | String description,
55 | String url) {
56 | this.key = key;
57 | this.name = name;
58 | this.state = State.fromCommitSatus(status);
59 | this.description = description;
60 | this.url = url;
61 | }
62 |
63 | public State getState() {
64 | return state;
65 | }
66 |
67 | public void setState(State state) {
68 | this.state = state;
69 | }
70 |
71 | public String getUrl() {
72 | return url;
73 | }
74 |
75 | public void setUrl(String url) {
76 | this.url = url;
77 | }
78 |
79 | public String getDescription() {
80 | return description;
81 | }
82 |
83 | public void setDescription(String description) {
84 | this.description = description;
85 | }
86 |
87 | public String getKey() {
88 | return key;
89 | }
90 |
91 | public void setKey(String key) {
92 | this.key = key;
93 | }
94 |
95 | public String getName() {
96 | return name;
97 | }
98 |
99 | public void setName(String name) {
100 | this.name = name;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/java/com/arcbees/vcs/util/JsonCustomDataStorage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 ArcBees Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | package com.arcbees.vcs.util;
18 |
19 | import com.arcbees.vcs.model.Comment;
20 | import com.arcbees.vcs.model.PullRequest;
21 | import com.google.gson.Gson;
22 | import com.google.gson.GsonBuilder;
23 | import com.google.gson.JsonSyntaxException;
24 | import com.google.gson.reflect.TypeToken;
25 |
26 | import jetbrains.buildServer.serverSide.CustomDataStorage;
27 |
28 | public class JsonCustomDataStorage {
29 | public static JsonCustomDataStorage create(CustomDataStorage dataStorage, Class clazz) {
30 | return new JsonCustomDataStorage(dataStorage, clazz);
31 | }
32 |
33 | public static JsonCustomDataStorage create(CustomDataStorage dataStorage, TypeToken typeToken) {
34 | return new JsonCustomDataStorage(dataStorage, typeToken);
35 | }
36 |
37 | private final CustomDataStorage dataStorage;
38 | private final Class clazz;
39 | private final TypeToken typeToken;
40 | private final Gson gson = new GsonBuilder()
41 | .registerTypeAdapter(PullRequest.class, new PolymorphicTypeAdapter())
42 | .registerTypeAdapter(Comment.class, new PolymorphicTypeAdapter())
43 | .create();
44 |
45 | private JsonCustomDataStorage(CustomDataStorage dataStorage,
46 | Class clazz) {
47 | this.dataStorage = dataStorage;
48 | this.clazz = clazz;
49 | typeToken = null;
50 | }
51 |
52 | private JsonCustomDataStorage(CustomDataStorage dataStorage,
53 | TypeToken typeToken) {
54 | this.dataStorage = dataStorage;
55 | this.typeToken = typeToken;
56 | clazz = null;
57 | }
58 |
59 | public T getValue(String key) {
60 | String value = dataStorage.getValue(key);
61 |
62 | T object;
63 | try {
64 | if (clazz != null) {
65 | object = gson.fromJson(value, clazz);
66 | } else {
67 | object = gson.fromJson(value, typeToken.getType());
68 | }
69 | } catch (JsonSyntaxException e) {
70 | object = null;
71 | }
72 |
73 | return object;
74 | }
75 |
76 | public void putValue(String key, T object) {
77 | String value = gson.toJson(object);
78 | dataStorage.putValue(key, value);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/vcs-utils/src/main/resources/buildServerResources/vcsSettings.jsp:
--------------------------------------------------------------------------------
1 | <%@ include file="/include.jsp" %>
2 | <%@ include file="/include-internal.jsp" %>
3 |
4 |
5 |
6 |
24 |
25 |