Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,20 @@
<!--<bamboo.version>5.11.3</bamboo.version> -->
<!--<bamboo.version>5.12.0.2</bamboo.version> -->

<bamboo.version>6.7.1</bamboo.version>
<bamboo.version>7.2.3</bamboo.version>
<!--<bamboo.data.version>5.10.0</bamboo.data.version> -->

<!--<amps.version>4.2.1</amps.version> -->
<!--<amps.version>6.2.1</amps.version> -->
<amps.version>6.2.9</amps.version>
<slf4j.version>1.6.4</slf4j.version>
<jgit.version>4.0.3.201509231615-r</jgit.version>
<amps.version>8.0.0-m2</amps.version>
<slf4j.version>1.7.3</slf4j.version>
<jgit.version>5.0.3.201809091024-r</jgit.version>
</properties>

<repositories>
<repository>
<id>central.maven.org</id>
<url>http://central.maven.org/maven2</url>
</repository>
<repository>
<id>repo1.maven.org</id>
<url>http://repo1.maven.org/maven2</url>
<url>https://mvnrepository.com/repos/central</url>
</repository>
<repository>
<id>jenkins-releases</id>
Expand All @@ -101,12 +97,25 @@
<id>jfrog-libs-releases</id>
<url>http://repo.jfrog.org/artifactory/libs-releases</url>
</repository>
<repository>
<id>attlasian</id>
<url>https://maven.atlassian.com/3rdparty/</url>
</repository>
<repository>
<id>spring</id>
<url>https://repo.spring.io/libs-milestone/</url>
</repository>
<repository>
<id>spring-plugins</id>
<url>https://repo.spring.io/plugins-release/</url>
</repository>

</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo1.maven.org</id>
<url>http://repo1.maven.org/maven2</url>
<id>central.maven.org</id>
<url>https://org.apache.maven.plugins</url>
</pluginRepository>
<pluginRepository>
<id>jfrog-libs-releases</id>
Expand All @@ -115,6 +124,13 @@
</pluginRepositories>

<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>11.2.0</version>
<scope>system</scope>
<!--<systemPath>D:/.m2/repository/com/oracle/ojdbc6/11.2.0.2.0/ojdbc6-11.2.0.2.0.jar</systemPath>-->
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down Expand Up @@ -245,19 +261,22 @@
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-bamboo-plugin</artifactId>
<version>${amps.version}</version>
<version>5.0.18</version>
<extensions>true</extensions>
<configuration>
<productVersion>${bamboo.version}</productVersion>
<productDataVersion>${bamboo.version}</productDataVersion>
<productVersion>5.0.18</productVersion>
<productDataVersion>5.0.18</productDataVersion>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ public BuildLoggerManager getBuildLoggerManager() {
new BuildRepositoryChangesImpl(change.getLastRevision(), commits);

if (!this.getVcsBranch().isEqualToBranchWith(change.getBranch()))
buildChanges.setOverriddenVcsBranch(this.getVcsBranch());
buildChanges.setActualBranch(this.getVcsBranch());

bandanaManager.setValue(PlanAwareBandanaContext.GLOBAL_CONTEXT,
change.getId(), change.getLastRevision());
Expand Down Expand Up @@ -1124,7 +1124,7 @@ private boolean isOnLocalAgent() {
String vcsRevisionKey,
File sourceDirectory, int depth) throws RepositoryException {
String originalVcsRevisionKey = vcsRevisionKey;
PlanKey actualKey = PlanKeys.getPlanKey(buildContext.getPlanKey());
PlanKey actualKey = buildContext.getTypedPlanKey();
final BuildLogger buildLogger = buildLoggerManager.getLogger(actualKey);
final boolean doShallowFetch =
USE_SHALLOW_CLONES && gc.isUseShallowClones() && depth == 1;
Expand Down Expand Up @@ -1376,8 +1376,7 @@ public CommitContext getFirstCommit() throws RepositoryException {
public void
createBranch(long repositoryId, String branchName,
BuildContext buildContext) throws RepositoryException {
PlanKey planKey = PlanKeys.getPlanKey(buildContext.getPlanKey());

PlanKey planKey = buildContext.getTypedPlanKey();
if (planKey != null) {
JGitRepository jgitRepo = new JGitRepository();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2012 Houghton Associates
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,21 +15,16 @@
*/
package com.houghtonassociates.bamboo.plugins.processor;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import com.atlassian.bamboo.plan.Plan;
import com.atlassian.bamboo.repository.RepositoryException;
import com.atlassian.bamboo.vcs.configuration.PlanRepositoryDefinition;
import org.apache.log4j.Logger;

import com.atlassian.bamboo.build.CustomBuildProcessor;
import com.atlassian.bamboo.build.fileserver.BuildDirectoryManager;
import com.atlassian.bamboo.builder.BuildState;
import com.atlassian.bamboo.configuration.AdministrationConfiguration;
import com.atlassian.bamboo.configuration.AdministrationConfigurationAccessor;
import com.atlassian.bamboo.plan.Plan;
import com.atlassian.bamboo.repository.RepositoryDefinition;
import com.atlassian.bamboo.repository.RepositoryException;
import com.atlassian.bamboo.utils.error.ErrorCollection;
import com.atlassian.bamboo.utils.i18n.I18nBeanFactory;
import com.atlassian.bamboo.utils.i18n.TextProviderAdapter;
Expand All @@ -43,6 +38,11 @@
import com.houghtonassociates.bamboo.plugins.dao.GerritService;
import com.opensymphony.xwork2.TextProvider;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;

/**
* Post processor which updates Gerrit after build completes
*/
Expand All @@ -62,10 +62,6 @@ public class GerritProcessor extends BaseConfigurableBuildPlugin implements
@Override
public void init(BuildContext buildContext) {
super.init(buildContext);

final List<RepositoryDefinition> repositories =
buildContext.getRepositoryDefinitions();

this.customConfiguration =
buildContext.getBuildDefinition().getCustomConfiguration();
}
Expand Down Expand Up @@ -164,42 +160,35 @@ private String buildStatusString(CurrentBuildResult results) {
}

@Override
public BuildContext call() throws InterruptedException, Exception {
final String buildPlanKey = buildContext.getPlanKey();
public BuildContext call() throws Exception {
final CurrentBuildResult results = buildContext.getBuildResult();
final Boolean runVerification =
Boolean.parseBoolean(customConfiguration.get(GERRIT_RUN));

logger.info("Run verification: " + runVerification);

List<PlanRepositoryDefinition> repos = buildContext.getVcsRepositories();
if (runVerification) {
final List<RepositoryDefinition> repositories =
buildContext.getRepositoryDefinitions();

for (RepositoryDefinition rd : repositories) {
if (rd.getRepository() instanceof GerritRepositoryAdapter) {
for (PlanRepositoryDefinition rd : repos) {
if (rd.asLegacyData().getRepository().getClass().isAssignableFrom(GerritRepositoryAdapter.class)) {
logger.info("Updating Change Verification...");
updateChangeVerification(rd, buildPlanKey, results);
updateChangeVerification(rd, results);
}
}
}

return buildContext;
}

private void
updateChangeVerification(RepositoryDefinition rd,
String buildPlanKey,
updateChangeVerification(PlanRepositoryDefinition rd,
CurrentBuildResult results) throws RepositoryException {
Long id = rd.asLegacyData().getId();
final GerritRepositoryAdapter gra =
(GerritRepositoryAdapter) rd.getRepository();
(GerritRepositoryAdapter) rd.asLegacyData().getRepository();
String revNumber =
results.getCustomBuildData().get("repository.revision.number");
final String vcsRevision =
buildContext.getBuildChanges().getVcsRevisionKey(rd.getId());
buildContext.getBuildChanges().getVcsRevisionKey(id);
final String prevVcsRevision =
buildContext.getBuildChanges()
.getPreviousVcsRevisionKey(rd.getId());
.getPreviousVcsRevisionKey(id);

final GerritService service = gra.getGerritDAO();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.atlassian.bamboo.resultsummary.ResultSummaryPredicates;
import com.atlassian.bamboo.storage.StorageLocationService;
import com.atlassian.spring.container.ContainerManager;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -176,7 +177,11 @@ public FilteredTestResults<TestClassResultDescriptor> getFilteredTestResults() {

public boolean isLogAccessible(BuildResultsSummary jobResults) {
if (jobResults != null) {
File logFile = new File(BuildLogUtils.getLogFileDirectory(jobResults.getPlanKey()), BuildLogUtils.getLogFileName(jobResults.getPlanKey(), jobResults.getBuildNumber()));

final StorageLocationService storageLocationService = (StorageLocationService) ContainerManager.
getComponent("storageLocationService");
File logFile = new File(storageLocationService.getBuildLogsDirectory(jobResults.getPlanKey()),
storageLocationService.getLogFileName(jobResults.getPlanKey(), Long.valueOf(jobResults.getBuildNumber())));
return logFile.canRead();
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/atlassian-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</web-resource>

<component-import key="i18nResolver" interface="com.atlassian.sal.api.message.I18nResolver"/>
<component-import key="branchIntegrationHelper" interface="com.atlassian.bamboo.plan.branch.BranchIntegrationHelper" />
<component-import key="branchIntegrationHelper" interface="com.atlassian.bamboo.plan.branch.VcsBranchIntegrationHelper" />
<component-import key="encryptionService" interface="com.atlassian.bamboo.security.EncryptionService" />
<component-import key="repositoryDefinitionManager" interface="com.atlassian.bamboo.repository.RepositoryDefinitionManager" />
<component-import key="decoratingAggregatedChainErrorAccessor" interface="com.atlassian.bamboo.logger.ErrorAccessor" />
Expand Down