Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bamboo Specs: NullPointerException when trying to add CVS repository

I'm trying to write a simple Bamboo spec which will check out source code from a CVS repository. A slightly modified version of the plan I'm trying to create as a starter is shown below

 Plan createPlan()
{
Plan plan = new Plan(new Project().name("Spec Testing").key("SPEC"), "Spec Plan", "PLAN")
.description("Plan generated from spec");

AtlassianModule atlassianModuleCvs = new AtlassianModule("com.atlassian.bamboo.plugin.system.repository:cvs");

Map<String,Object> cvsConf = new HashMap<String,Object>();
cvsConf.put("cvsRoot", "/");
cvsConf.put("authType", "password");
cvsConf.put("password", "password123");
cvsConf.put("quietPeriod", 2);
cvsConf.put("module", "sw");
cvsConf.put("selectedVersionType", "branch");
cvsConf.put("branchName", "REL-1-0");

Map <String,Object> srvConf = new HashMap<String,Object>();
srvConf.put("repository.cvs", cvsConf);

plan.planRepositories(new AnyVcsRepository(atlassianModuleCvs)
.name("CVS Repository")
.serverConfiguration(srvConf));

return plan;
}

When I run the spec initially, everything seems fine until I try to access the plan in Bamboo, at which point I get an internal server error with a NullPointerException. The full stack trace is here, but I think the key parts are the following lines where it tries to read the plan repository definition:

io.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.NullPointerException
	at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:156)
	at io.atlassian.util.concurrent.LazyReference.get(LazyReference.java:116)
	at com.atlassian.bamboo.plan.cache.AbstractImmutableChain.getPlanRepositoryDefinitions(AbstractImmutableChain.java:231)
	at com.atlassian.bamboo.plan.PlanHelper.getPlanRepositoryDefinitions(PlanHelper.java:49)
	at com.atlassian.bamboo.plan.PlanHelper.getDefaultPlanRepositoryDefinition(PlanHelper.java:69)
	at com.atlassian.bamboo.plan.branch.ChainBranchUtils.getANameFromBranch(ChainBranchUtils.java:64)
	at com.atlassian.bamboo.plan.branch.ChainBranchUtils.getSubstitutedVcsBranchDisplayNameWithoutContextChange(ChainBranchUtils.java:51)
	at com.atlassian.bamboo.plan.branch.ChainBranchUtils.getChainBranchNameWithoutContextChange(ChainBranchUtils.java:110)
	at com.atlassian.bamboo.plan.branch.ChainBranchUtils.lambda$getChainBranchNameInTemporaryContext$3(ChainBranchUtils.java:101)
	at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:196)
	at com.atlassian.bamboo.plan.branch.ChainBranchUtils.getChainBranchNameInTemporaryContext(ChainBranchUtils.java:100)
	at com.atlassian.bamboo.plan.branch.ChainBranchUtils.getChainBranchName(ChainBranchUtils.java:95)
	at com.atlassian.bamboo.ww2.beans.DecoratedNavObjectFactoryImpl.getSubstitutedBranchName(DecoratedNavObjectFactoryImpl.java:132)
...

Am I doing something wrong here? I know we should really move away from CVS, but that's not something we can easily do right now. I'm using Bamboo 6.1.1.

1 answer

0 votes

try to go other way around. create plan with CVS repository and then go to Plan configuration and choose "View plan as Bamboo Spec"Screen Shot 2017-09-11 at 21.24.13.png

I've just tried this, but I'm still getting the same problem. I've attached the generated code below, if it helps at all.

Also, I tried this with SVN and Mercurial to see if they worked, which they do. The only difference I can see is that branchConfiguration is called for SVN and Mercurial, but not for CVS. Is there some branch configuration I need to populate?

import com.atlassian.bamboo.specs.api.BambooSpec;
import com.atlassian.bamboo.specs.api.builders.AtlassianModule;
import com.atlassian.bamboo.specs.api.builders.BambooKey;
import com.atlassian.bamboo.specs.api.builders.BambooOid;
import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
import com.atlassian.bamboo.specs.api.builders.permission.PlanPermissions;
import com.atlassian.bamboo.specs.api.builders.plan.Plan;
import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
import com.atlassian.bamboo.specs.api.builders.plan.configuration.ConcurrentBuilds;
import com.atlassian.bamboo.specs.api.builders.project.Project;
import com.atlassian.bamboo.specs.api.builders.repository.AnyVcsRepository;
import com.atlassian.bamboo.specs.api.builders.repository.VcsChangeDetection;
import com.atlassian.bamboo.specs.util.BambooServer;
import com.atlassian.bamboo.specs.util.MapBuilder;

@BambooSpec
public class PlanSpec {
public static void main(String... argv) {
//By default credentials are read from the '.credentials' file.
BambooServer bambooServer = new BambooServer("http://buildserver:8085");

Plan plan = new Plan(new Project()
.oid(new BambooOid("jfym841e38jn"))
.key(new BambooKey("SPEC"))
.name("Spec Testing"),
"Plan Name",
new BambooKey("PLAN"))
.oid(new BambooOid("jfox0io69gyd"))
.description("Plan created from (enter repository url of your plan)")
.pluginConfigurations(new ConcurrentBuilds()
.useSystemWideDefault(false)
.maximumNumberOfConcurrentBuilds(20))
.planRepositories(new AnyVcsRepository(new AtlassianModule("com.atlassian.bamboo.plugin.system.repository:cvs"))
.name("Test")
.oid(new BambooOid("jft2oceerdpb"))
.serverConfiguration(new MapBuilder()
.put("repository.cvs", new MapBuilder()
.put("cvsRoot", "/path/to/cvs/server")
.put("password", "BAMSCRT@0@0@cD10yGZALomfb2AqsUj5lQ==")
.put("quietPeriod", 2)
.put("module", "sw")
.put("branchName", "REL-1-0")
.put("authType", "password")
.put("selectedVersionType", "branch")
.build())
.build())
.changeDetectionConfiguration(new VcsChangeDetection()))

.planBranchManagement(new PlanBranchManagement()
.delete(new BranchCleanup()));

bambooServer.publish(plan);

PlanPermissions planPermission = new PlanPermissions(new PlanIdentifier("SPEC", "PLAN"))
.permissions(new Permissions()
.userPermissions("cfarr", PermissionType.ADMIN, PermissionType.CLONE, PermissionType.EDIT)
.groupPermissions("bamboo-admin", PermissionType.ADMIN)
.loggedInUserPermissions(PermissionType.VIEW)
.anonymousUserPermissionView());

bambooServer.publish(planPermission);
}
}

 

Sorry for delay. Confirming it's a bug in Bamboo Specs import of AnyVcsRepository entity.

Please watch https://jira.atlassian.com/browse/BAM-18682 for updates and fix version.

Thanks for that, I'll keep an eye out!

The BAM-18682 has been fixed in Bamboo 6.2.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo Data Center 8.1 is now available

G’day Bamboo customers, Bamboo DC 8.1 is now available with it the following features and programs: SAML 2.0, OpenID Connect, and Crowd SSO In order to help admins with a simplified user manage...

204 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you