Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 SharedCredentials

I'm trying to create a bamboo java spec for a simple plan creation. I don't see the plan created after enabling the scan for bamboo spec in linked repository. How to use the existing shared credentials to authenticate? Please let me know.

3 answers

1 accepted

1 vote
Answer accepted

Hi Manasa,

I'm afraid you aren't facing the same issue from the question you mentioned. From what I understood, @Ryan Schaaf is using a Bitbucket Server repository to store his code and, in this case, there is no need to trigger the specs detection using a webhook (it's done through the application links).

As you probably already know, there is no way to create an application link between Bamboo and Bitbucket Cloud yet and that's the reason why the webhook is needed in this case.

On Bamboo 6.5.1 we added an option in Repository Configuration>>Specs Status to manually scan the repository for specs code without using a webhook: 

Screen Shot 2018-07-10 at 15.13.09.png
While the improvement request mentioned by my colleague @Alexey Chystoprudov(BAM-19837) is not implemented, you can be creative and develop an external script calling the same endpoint used by the "Scan" button.

for example:

curl -u <USER>:<PASSWORD> -H 'content-type: application/json' -H 'accept:application/json' -X POST http://<bambooURL>/rest/api/latest/repository/<repositoryID>/scanNow

ps. You can find the <repositoryID> hovering the mouse over the linked repository name.

But first, of course, you'll need to upgrade Bamboo to 6.5.1 to have this endpoint available.

Please let me know what do you think about this workaround.

thanks.

Hi Gabriel,

As per my observation, when i create a plan using  bamboo.yaml in my project all i need to trigger is the webhook url provided in the Bamboo Specs tab. The plan is getting triggered for every new commit as well without any webhooks after the plan has been created.

https://company.com/rest/api/latest/repository/scan?repositoryId=

 

bamboo-test.git   

   |_ bamboo-specs

          |_ bamboo.yaml

 

When i create a bamboo plan using a java spec, i need to trigger using the webhook to create the plan/update any changes to plan using the spec. It doesn't trigger any code updates later, manually running the curl for new code commits works. 

 

- bamboo-specs

   |_ src/main/java/CreatePlan.java

 

curl -X POST -H "Content-Type: application/json" https://company.com/rest/triggers/1.0/remote/changeDetection?planKey=TEST-BT&skipBranches=false

Above curl works for the plan created through java spec for new commits. It doesn't trigger the plan for new code changes just like the one created by yaml.

Please let me know your thoughts!

 

Thanks!

Hi Manasa,

I'm not sure if we are talking about the same thing here, let's see.

When you call the "https://company.com/rest/api/latest/repository/scan?repositoryId=" API endpoint (using cURL o via SCM webhook),  Bamboo will trigger the Repository Stored Specs feature that will be responsible for "sweeping around" your repository looking for specs code (it doesn't matter if it is in Java or YAML). It will neglect all code that can possibly be in your repository other than the files inside the repositoryRoot/bamboo-specs/ folder. If Bamboo finds a possible specs code, it will pull and process this code using an environment specifically developed for this purpose.

On the other hand, the "https://company.com/rest/triggers/1.0/remote/changeDetection?planKey=TEST-BT&skipBranches=false" API is designed to trigger the change detection functionality and check if there were changes in the default repository for the plan specified in the API URL (in this case: TEST-BT) since the previous build. If there were change, the entire repository will be checked out and all the stages/jobs specified in your plan configuration will be executed. This procedure has no relations to Repository Stored Specs and Bamboo will not process you specs project unless this plan was meant to process you Java Specs as a regular Maven/Java project.

From my understanding, this is what you're experiencing right now:

If you have the specs code (Java or YAML) in the repository and curl the "https://company.com/rest/api/latest/repository/scan?repositoryId=" endpoint, Bamboo Specs will run and create/update your plans but when you call the "https://company.com/rest/triggers/1.0/remote/changeDetection?planKey=TEST-BT&skipBranches=false" API endpoint, the builds get triggered but your plans are being updated by Bamboo Specs.

Is this correct? 

thanks

Hi Gabriel,

So i'm finding a difference in code detection for a JAVA Spec and YAML.

"https://company.com/rest/api/latest/repository/scan?repositoryId=" endpoint is helping in triggering the spec updates for java and YAML but after the plan is created for any new code commits,

Plan created by YAML

- Triggers a build for all new commits without any webhooks.

Screen Shot 2018-07-11 at 4.20.44 PM.png

Plan created by Java Spec

- Doesn't trigger any build.

 

Hope its clear, let me know. Thanks!

Hi Manasa,

Now I think I got it! 

This is probably happening because when you use YAML, even though you are not specifying any repository or/and any build trigger in the configuration file, Bamboo will assign the repository you're using to store the specs file as default and will automatically define a repository polling trigger type to it.

If you want to add a trigger to the plan generated by your java RSS specs code, you'll need to specify it in the code, please see the example below:

@BambooSpec
public class PlanSpec {

public Plan plan() {
final Plan plan = new Plan(new Project()
.key(new BambooKey("PROJ"))
.name("Project")
.description("Plan"),
"TEST",
new BambooKey("TEST"))
.pluginConfigurations(new ConcurrentBuilds()
.useSystemWideDefault(false))
.stages(new Stage("Default Stage")
.jobs(new Job("Default Job",
new BambooKey("JOB1"))
.tasks(new VcsCheckoutTask()
.description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()))))
.linkedRepositories("JAVA_RSS")
.triggers(new RepositoryPollingTrigger())
.planBranchManagement(new PlanBranchManagement()
.delete(new BranchCleanup())
.notificationForCommitters());
return plan;

.linkedRepositories("JAVA_RSS") - Responsible for assigning a default repository to the plan, in this case, the plan will use a linked repository called "JAVA_RSS" 

.triggers(new RepositoryPollingTrigger()) - Responsible for adding a build trigger to the plan, in this case, a "Repository Polling" trigger which will scan the repo for code change every 180 seconds by default.

Could you please try that? Let us know the results.

Thanks

Hi Gabriel,

Thanks for the detailed explanation. I tried above and it worked as expected. Is there a way yaml doesn't trigger repository polling by default and can yaml stages and jobs have KEY and NAME defined instead of going with default names?

Please let me know. Thanks!

Hi Manasa,

I'm glad you got this working.

Regarding your question, I'm afraid not, YAML specs was meant to be a simpler alternative and to accomplish this, some sacrifices were required. If you want to have more control of your plans, Java specs is the best option, for sure.

To help our community, please don't forget to accept the correct answer for this thread.

thanks

@Gabriel Ribeiro Thank you. I couldn't able to accept your last comment as an answer there is no option available for it.

 Hi Manasa,

Are you talking about the shared credentials for the repository authentication? If you are using a linked repository, your plan will use the credential set there, if you are using a plan repository, you'll need to define the shared credentials in your specs code:

i.e

Plan plan = new Plan(project, planName, planKey)
    .planRepositories(new GitRepository()
        .name("my-repository")
        .url("ssh://git@bitbucket.org:my-company/my-repository.git")
        .branch("master")
        .authentication(new SharedCredentialsIdentifier("identifier")));

(from Bamboo Specs Reference)

But, if you are talking about the permissions used by Bamboo to run your specs code, it does not use any specific user, Bamboo uses a system account with the permissions you set specifically for the repository where you're storing the specs code.

thanks

Hi Gabriel, Thank you for the response. So when i try to run the java spec from my local computer i use my credentials in .credentails file. When i try to add the java spec to a git repository and enable bamboo spec scanner, i don't see the plan created. We have shared credentials to authenticate the repo on Bamboo. Does your code help me with my issue?

Hi Manasa,

I don't think so, your specs code is probably not running because your repository does not have access rights to the project where you're trying to create/edit the plan. When using RSS (repository stored specs) you need to explicitly give permission for the repository to the project (Project settings > Bamboo Specs repositories).

thanks

I have added that settings but i still don't see my plan has been created. Do i need to have .credentials file available within bamboo-specs repository?

No, the .credentials file is not used in repository stored specs, this is only used while publishing your plans using maven or the IDE.

  • Is your java specs code inside a bamboo-specs folder in your repository? 
  • Are you using Bitbucket server? If not, are you sure your SCM is being able to reach the RSS webhook endpoint?
  • Are there any error messages regarding specs in Bamboo logs?

thanks.

repo

- bamboo-specs

    -src/main/java/CreatePlan.java

 

Yes my repo has connectivity with the Bamboo.

Did you get any email notification from Bamboo with specs execution, also check folder <BAMBOO_HOME>/xml-data/repository-specs/<REPO_ID>/<EXECUTION_FILE>.log

I din't get any email and tried to check my bamboo-home folder i don't see repository-specs folder.

bamboo-home/xml-data/

- build-dir

-builds

-configuration

Let me know if i can check any pattern in the logs for the issue.

Do i have to connect my Bamboo and Bitbucket server using application link only?

where can i find the application link.

 

Currently, i had Repository host as Git for my Linked Repository configuration on bamboo.

Yes, you have to connect it via AppLink and create Bitbucket Server repository at Bamboo side. Or you can trigger Repository stored specs detection by Scan button (from Bamboo 6.5.1). Or trigger detection with REST call (from Bamboo 6.5)

Is there a way i can make it work if my repository host as GIT? We use Bitbucket cloud. My current Linked Repository - Git configuration on bamboo doesn't generate the plans as per the java spec which has the bamboo scanner enabled, which works from my IDE.

Let me know if there any steps to configure when my repository host is GIt/Bitbucket cloud. Should we need to use the Linked repository if its Git/Bitbucket cloud?

 

Thank you!

Let me know your version of Bamboo.

If it's lower than 6.5, then there's no support for Bamboo Specs at repository unless Bitbucket Server.

We are using 6.5.0 version.

 

Screen Shot 2018-07-06 at 2.59.58 PM.png

I see its asking to enable webhook url. Is there a way bamboo spec scan can be enabled without using the webhook? Please let me know.

All right. There's no such functionality for pure Git or Bitbucket Cloud, you can watch and vote for it at this feature request: https://jira.atlassian.com/browse/BAM-19837

I see its the same issue but it worked for him. Let me know if its a different version of bamboo supports it.

 

https://community.atlassian.com/t5/Bamboo-questions/bamboo-specs-not-running-from-linked-repository/qaq-p/774770#U839018

Suggest an answer

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

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

219 views 4 6
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