-
Bug
-
Resolution: Fixed
-
Low
-
7.1.2
-
None
-
Severity 3 - Minor
-
Issue Summary
Creating a Bitbucket Server repository in RSS mode using OpenSSH keys doesn't work. Bamboo throws the following error message:
26-Nov-2020 14:08:16 com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Clone url or ssh key pair is not valid 26-Nov-2020 14:08:16 java.lang.IllegalArgumentException: com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Clone url or ssh key pair is not valid 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$validateAndCreateRepositoryObjects$21(PlanConfigImportServiceImpl.java:1259) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:129) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.validateAndCreateRepositoryObjects(PlanConfigImportServiceImpl.java:1235) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$modifyTopLevelPlanFunction$2(PlanConfigImportServiceImpl.java:560) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.core.ScopedExclusionServiceImpl.tryWithLock(ScopedExclusionServiceImpl.java:74) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.modifyExistingTopLevelPlan(PlanConfigImportServiceImpl.java:461) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$importPlan$0(PlanConfigImportServiceImpl.java:426) 26-Nov-2020 14:08:16 at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.persistence.BambooTransactionHibernateTemplate.execute(BambooTransactionHibernateTemplate.java:28) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.importPlan(PlanConfigImportServiceImpl.java:405) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.DefaultSpecsConsumer.importPlanProperties(DefaultSpecsConsumer.java:120) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.importers.PlanImporterProvider.lambda$getEntityProvider$1(PlanImporterProvider.java:38) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.AllTypesSpecsImporter.importBambooYamlsWithImporter(AllTypesSpecsImporter.java:88) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.AllTypesSpecsImporter.importBambooYamlsOfAllTypes(AllTypesSpecsImporter.java:52) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.JavaSpecsImportServiceImpl.lambda$processSpecs$2(JavaSpecsImportServiceImpl.java:77) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.SpecsOptimizeProcessor.processSpecs(SpecsOptimizeProcessor.java:42) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.JavaSpecsImportServiceImpl.processSpecs(JavaSpecsImportServiceImpl.java:63) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.runBambooSpecs(RepositoryStoredSpecsServiceImpl.java:175) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.runRssDetection(RssDetectionServiceImpl.java:330) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.detection.RssDetectionRunnable.run(RssDetectionRunnable.java:42) 26-Nov-2020 14:08:16 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 26-Nov-2020 14:08:16 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 26-Nov-2020 14:08:16 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 26-Nov-2020 14:08:16 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) 26-Nov-2020 14:08:16 at java.lang.Thread.run(Thread.java:748) 26-Nov-2020 14:08:16 Caused by: com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Clone url or ssh key pair is not valid 26-Nov-2020 14:08:16 at com.atlassian.bamboo.plugins.stash.v2.exporter.BitbucketServerExporter.validateOrGenerateSshKeys(BitbucketServerExporter.java:325) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.plugins.stash.v2.exporter.BitbucketServerExporter.importLocationData(BitbucketServerExporter.java:290) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.plugins.stash.v2.exporter.BitbucketServerExporter.importLocationData(BitbucketServerExporter.java:71) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.exporters.RepositoryExporterImpl.importRepository(RepositoryExporterImpl.java:275) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$validateAndCreateRepositoryObjects$21(PlanConfigImportServiceImpl.java:1241) 26-Nov-2020 14:08:16 ... 28 more
Steps to Reproduce
- Create an application link to Bitbucket Server if you haven't one already.
- Create/ add a Bitbucket Server repository to your plan using Java Specs:
Java Specs
.planRepositories(new BitbucketServerRepository() .name("myRepository") .repositoryViewer(new BitbucketServerRepositoryViewer()) .server(new ApplicationLink() .name("<applicationName>")) .projectKey("<projectKey>") .repositorySlug("<repositorySlug>") .sshPublicKey("<sshPublicKey>") .sshPrivateKey("<sshPrivateKey>") .sshCloneUrl("<sshCloneUrl>") .branch("master"))
Example.planRepositories(new BitbucketServerRepository() .name("BbS") .repositoryViewer(new BitbucketServerRepositoryViewer()) .server(new ApplicationLink() .name("Bitbucket 7.6.0") .id("1dc14b2e-02aa-38c3-89f4-a2d782eb18dc")) .projectKey("SPECS") .repositorySlug("godzilla") .sshPublicKey("ssh-rsa AAAAB3N...") .sshPrivateKey("BAMSCRT@0@0@2e8329V...") .sshCloneUrl("ssh://git@bitbucket760:7999/specs/godzilla.git") .branch("master"))
- Create an SSH key pair using the following commands (the authentication is supposed to work whether you choose a password or not):
ssh-keygen -t rsa -C "your_email@example.com"
According to man ssh-keygen when the -m option is not used OpenSSH will write newly-generated private keys in its own format.
- Copy the public key to your Java Specs code.
- Take the private key and access Bamboo to encrypt it using the following steps:
- Use the encrypted private key in your Java Specs code.
- Go to Bitbucket Server and add the public key to the repository you're trying to add to your plan in the Java Specs code.
- Taking the example above I should be adding my public key to the repository named godzilla.
- Push the changes made to your Java Specs code to your repository.
- Access the Bamboo admin > Linked repositories page and find your repository.
- Go to the Specs status tab.
- Try to Scan your repository.
Expected Results
Bamboo will add a repository to your plan managed via Java Specs and you'll see a "Specs execution successful" message.
Actual Results
The scan process fails with "Error in Bamboo Specs" and the below exception is thrown in the Specs logs:
26-Nov-2020 14:08:16 com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Clone url or ssh key pair is not valid 26-Nov-2020 14:08:16 java.lang.IllegalArgumentException: com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Clone url or ssh key pair is not valid 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$validateAndCreateRepositoryObjects$21(PlanConfigImportServiceImpl.java:1259) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:129) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.validateAndCreateRepositoryObjects(PlanConfigImportServiceImpl.java:1235) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$modifyTopLevelPlanFunction$2(PlanConfigImportServiceImpl.java:560) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.core.ScopedExclusionServiceImpl.tryWithLock(ScopedExclusionServiceImpl.java:74) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.modifyExistingTopLevelPlan(PlanConfigImportServiceImpl.java:461) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$importPlan$0(PlanConfigImportServiceImpl.java:426) 26-Nov-2020 14:08:16 at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.persistence.BambooTransactionHibernateTemplate.execute(BambooTransactionHibernateTemplate.java:28) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.importPlan(PlanConfigImportServiceImpl.java:405) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.DefaultSpecsConsumer.importPlanProperties(DefaultSpecsConsumer.java:120) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.importers.PlanImporterProvider.lambda$getEntityProvider$1(PlanImporterProvider.java:38) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.AllTypesSpecsImporter.importBambooYamlsWithImporter(AllTypesSpecsImporter.java:88) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.AllTypesSpecsImporter.importBambooYamlsOfAllTypes(AllTypesSpecsImporter.java:52) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.JavaSpecsImportServiceImpl.lambda$processSpecs$2(JavaSpecsImportServiceImpl.java:77) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.SpecsOptimizeProcessor.processSpecs(SpecsOptimizeProcessor.java:42) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.rss.JavaSpecsImportServiceImpl.processSpecs(JavaSpecsImportServiceImpl.java:63) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.runBambooSpecs(RepositoryStoredSpecsServiceImpl.java:175) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.RssDetectionServiceImpl.runRssDetection(RssDetectionServiceImpl.java:330) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.detection.RssDetectionRunnable.run(RssDetectionRunnable.java:42) 26-Nov-2020 14:08:16 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 26-Nov-2020 14:08:16 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 26-Nov-2020 14:08:16 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 26-Nov-2020 14:08:16 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) 26-Nov-2020 14:08:16 at java.lang.Thread.run(Thread.java:748) 26-Nov-2020 14:08:16 Caused by: com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException: Clone url or ssh key pair is not valid 26-Nov-2020 14:08:16 at com.atlassian.bamboo.plugins.stash.v2.exporter.BitbucketServerExporter.validateOrGenerateSshKeys(BitbucketServerExporter.java:325) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.plugins.stash.v2.exporter.BitbucketServerExporter.importLocationData(BitbucketServerExporter.java:290) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.plugins.stash.v2.exporter.BitbucketServerExporter.importLocationData(BitbucketServerExporter.java:71) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.exporters.RepositoryExporterImpl.importRepository(RepositoryExporterImpl.java:275) 26-Nov-2020 14:08:16 at com.atlassian.bamboo.configuration.external.PlanConfigImportServiceImpl.lambda$validateAndCreateRepositoryObjects$21(PlanConfigImportServiceImpl.java:1241) 26-Nov-2020 14:08:16 ... 28 more
Workaround
Check the content of your private key:
-----BEGIN OPENSSH PRIVATE KEY-----
If it starts with the message above you'll need to convert it to RSA format following these instructions:
- Backup your private key.
- Run the following command to convert the key:
ssh-keygen -p -N "" -m pem -f /path/to/private/key
- Check the content again and you should now see the following line:
-----BEGIN RSA PRIVATE KEY-----
- is related to
-
BAM-20246 SSH Key authentication fails when RFC4716 format Keys used
-
- Closed
-
-
BAM-19764 Support Ed25519 SSH keys for SSH transport
- Closed
- has action
-
BDEV-16789 Loading...