youngmon/atlassian-qna huggingface dataset:
Add user in Repository Using REST API
Asked by Rahul Jakhmola:

Hi Experts- I need to add user in given *Repository* using **API**. Can anyone help me where I can find API to achieve this task. Thanks!


Answers:
author: Leo
body: Hi [@Rahul Jakhmola](/t5/user/viewprofilepage/user-id/4094779)

Below API call would help you to add user to a repository

```
/REST/API/1.0/PROJECTS/{PROJECTKEY}/REPOS/{REPOSITORYSLUG}/PERMISSIONS/USERS?NAME&PERMISSION
```

You can refer [THIS](https://docs.atlassian.com/bitbucket-server/rest/4.9.1/bitbucket-rest.html#idp2183504) article for more details

BR,

Leo

comments: author: Rahul Jakhmola
body: Thanks Leo for the help :)


Tags: bitbucket-server

server
"let's put some bits in your bucket" missing.
Asked by brunobma:

When creating a new empty git repository in bitbucket, there used to be a custom git command to change the remote URL on my local repository to the Bitbucket repository.

It was a real time-saver.

It had the title: "let's put some bits in your bucket".

I can't find it anymore. What happened to it?

How do i set up origin in my local repo?

Thanx in advance.


Answers:
author: Theodora Boudale
body: Hi [@brunobma](/t5/user/viewprofilepage/user-id/4153317) ,

This page still shows when you create an empty repository in Bitbucket Cloud. If you select to create a README or a .gitignore (these are both options in the Create repository page), then the repo is not empty, it will have a commit with the README or .gitignore, so this page won't show.

If you want to create an empty repo, select 'No' for both 'Include a README?' and 'Include .gitignore?' options in the Create repository page, and you'll see the "Let's put some bits in your bucket" page.

You can add a remote to your local repo the following way:

If you use ++HTTPS++:

```
git remote add origin https://username@bitbucket.org/workspace-id/repo-slug.git
```

where   
**username** replace with the username of your own Bitbucket account  
**workspace-id** replace with the workspace ID that owns the repo  
**repo-slug** replace with the repository slug for the new repo you created

If you use ++SSH++:

```
git remote add origin git@bitbucket.org:workspace-id/repo-slug.git
```

where   
**workspace-id** replace with the workspace ID that owns the repo  
**repo-slug** replace with the repository slug for the new repo you created

Please feel free to let me know if you have any questions.

Kind regards,  
Theodora

comments: author: habpygo
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) and [@brunobma](/t5/user/viewprofilepage/user-id/4153317) . I had exactly the same problem and this, "If you want to create an empty repo, select 'No' for both 'Include a README?' and 'Include .gitignore?' options in the Create repository page, and you'll see the "Let's put some bits in your bucket" page." indeed was the answer.  

In my case it was the .gitignore file that was generated. Why is Atlassian not turn it off as a default start. I thinkg that most devs are first building on their local machine and only later push it up.  
My two cents.  
Kind regards,  
Harry


Tags: bitbucket-cloud

cloud
Something went wrong while attempting to validate your credentials
Asked by Michal Bystricky:

Hello Atlassian community,

I am unable to log in (this is another account). I tried all the comments but nothing worked for me:

- different browsers  
- different computers or/and mobiles  
- removing caches, cookies  
- logging out of all Google accounts  
- changing password

But I am still getting this error message: Something went wrong while attempting to validate your credentials

Could you please advise?

Thank you,  
Michal


Answers:
author: Michal Bystricky
body: Fixed by changing the Internet connection.

Not sure if this is related, but the IP address is from Netherlands and before it was from Slovakia.

comments: author: Shane Lewis
body: What do you mean exactly when you say "fixed by changing the internet connection"?

I'm having the same problem.


author: foghills
body: Same problem - same solution


Tags: bitbucket-cloud

cloud
Cant' register app
Asked by Luis Javier Gonzalez:

Hi guys,  

I'm trying to follow the tutorial here

<https://developer.atlassian.com/cloud/bitbucket/getting-started/>

When i triy to input the url i get this response

"The add-on server wasn't able to authorize your request. Try again, or contact the add-on vendor for help."  

I can access the atlassian-connect.json through the browser so the ssh tunnel is working. Any clue of what is going on?  

Thanks


Answers:
author: Luis Javier Gonzalez
body: All right, just in case someone else gets this problem too.  

I was usingg remote tunneling using a custom ec2 instance. So i wasnt able to use https. Using ngrok with https solved the error i posted above.  

Now the documentation should be updated. You need to modify the "key" key inside the json that the example app creates. There is an error about this displayed but is not clear enough IMO.


Tags: bitbucket-cloud

cloud
Checkstyle pipe provides a report with summary information only
Asked by Leonid S_:

I was testing checkstyle pipe, but report always show summary information only.

And it says: "There were no annotations provided in this report."

![checkstyle_report.png](https://community.atlassian.com/t5/image/serverpage/image-id/117397iEC6B6303C8F9E7F8/image-size/large?v=v2&px=999 "checkstyle_report.png")

```

- step:
    name: PHPCS
    script:
      - php phpcs.phar test.php --report=checkstyle > checkstyle.xml
    after-script:
      - pipe: atlassian/checkstyle-report:0.2.0
        variables:
          CHECKSTYLE_RESULT_PATTERN: '.*/checkstyle.xml$'
```

And no annotations in the Pull Request view.

Report looks like:

```
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="3.5.8">
<file name="test.php">
 <error line="2" column="1" severity="error" message="Missing file doc comment" source="PEAR.Commenting.FileComment.Missing"/>
</file>
</checkstyle>
```

What am I missing?

Log:

Status: Downloaded newer image for bitbucketpipelines/checkstyle-report:0.2.0  
Submitted report. Response:200 OK  
Exception thrown:java.lang.IllegalArgumentException: 'other' is different type of Path  
java.lang.IllegalArgumentException: 'other' is different type of Path  
at sun.nio.fs.UnixPath.relativize(UnixPath.java:416)  
at sun.nio.fs.UnixPath.relativize(UnixPath.java:43)  
at com.atlassian.bitbucket.pipelines.checkstyle.report.Main.lambda$main$3(Main.java:155)  
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)  
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)  
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)  
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)  
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)  
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)  
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)  
at com.atlassian.bitbucket.pipelines.checkstyle.report.Main.main(Main.java:158)


Answers:
author: mkleint
body: Thank you for the detailed report Leonid.

You've found a bug in the checkstyle report. I've incorrectly assumed that file paths generated by all tools are absolute but that doesn't appear to be the case for phpcs. I've released a new version of the pipe that should fix the problem. Can you try again with version 0.2.1?

Thanks and apologies.

comments: author: Leonid S_
body: It works now. Thank you for a quick fix.


Tags: bitbucket-pipelines

annotation

cloud

code-insight
Getting Error while creating war from bitbucket pipeline (Could not determine java version from '11)
Asked by Aurangzeb:

image: qlik/gradle

FAILURE: Build failed with an exception.

\* Where:  
Build file '/opt/atlassian/pipelines/agent/build/ProjectName/build.gradle' line: 8

\* What went wrong:  
A problem occurred evaluating root project 'ProjectName'.  
\> Could not determine java version from '11'.

Actually i want to create build using pipline with java 11 version but i am getting the above error.Any help will be apreciated.


Answers:
author: Theodora Boudale
body: Hi [@Aurangzeb](/t5/user/viewprofilepage/user-id/1452167) ,

Could you attach here the log file for the build that fails? This way we can see what commands are executed and the full output, so we can better help you. Please make sure to sanitize any private/sensitive info in the log file before sharing it here.

Kind regards,  
Theodora


Tags: bitbucket-cloud

bitbucket-pipelines

java
Bitbucket pipelines: Do not download the artifact for the next step
Asked by Wilber Marcel da Silva:

```
I generate my * .war artifact normally, but in the next step I use a manual step and I would not like you to download the artifact, I just echo it, then in the next step, the artifact has to be downloaded.The problem here is not to download the artifact, this is making it normal, I would just like to know if I can configure a step to not download this artifact to save time in my pipeline.


As you can see in the image below, I would like the "Deploy Start (Manual)" step not to download the artifacts, but the following steps can follow the normal flow by downloading.
![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/117367i579ED236B61B34E3/image-size/large?v=v2&px=999 "image.png")
```


Answers:
author: Theodora Boudale
body: Hi [@Wilber Marcel da Silva](/t5/user/viewprofilepage/user-id/4139405) ,

I'm afraid that this is not possible at the moment.

We have a feature request for what you are asking in our issue tracker:

* <https://jira.atlassian.com/browse/BCLOUD-16728>

I would suggest that you add your vote in that feature request (by selecting the **Vote for this issue** link), as the number of votes helps the development team and product managers better understand the demand for new features. You can also add yourself as a watcher (by selecting the **Start watching this issue** link) if you'd like to get notified via email on updates. When there is an update, it will get posted in that feature request.

Please note though that we don't provide ETAs and implementation of new features is done as per our policy here: <https://confluence.atlassian.com/cloud/new-features-744721668.html>.

Please feel free to let me know if you have any questions.

Kind regards,  
Theodora


Tags: bitbucket-cloud

bitbucket-pipelines
Issue with pipeline service mysql and ansible connection
Asked by AS:

(I'm sorry I couldnt work out how to pase code into the code block, and retain its formatting. Ive cleaned up where needed to make readable)  

Basically, I can not get ansible to connect and create a user. Tried a few different options, but I always get back to some variation of:  

> unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials.  
> Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

```
definitions:
services:
  mysql:
  image: mysql:5.7
  variables:
  MYSQL_RANDOM_ROOT_PASSWORD: 'yes' 
  MYSQL_USER: 'test_user'
  MYSQL_PASSWORD: 'test_user_password'

pipelines:
default:
  - parallel:
  - step:
name: test
  services: 
  - mysql

script:
  - apt-get update && apt-get install -y mysql-client
  - mysql -h 127.0.0.1 -u test_user -ptest_user_password -e "SHOW DATABASES"
  - ansible-playbook ci.yml -i hosts --connection=local
```

The SHOW DATABASES line works.  

However, when the ansible playbook gets to my task:

```

- name: add dev user to database
mysql_user: 
? name: '{{backend_database.user}}'
? password: '{{backend_database.pass}}'
? login_password: 'test_user_password'
? login_user: 'test_user'
? host: '{{backend_database.address}}'
? priv: '*.*:ALL'
? state: present
become: true

```

I always get the error above.  

I've tried so many combinations of things and always fails here.  
Includingm adding to the ansible task:

```

login_unix_socket: '/var/run/mysqld/mysqld.sock'
login_unix_socket: /var/lib/mysql/mysql.sock
```

<br />

Any pointers or advice on things to look into would be greatly appreciated. I'm very confused at what I'm missing here.  

To be clear, this works locally on my vagrant box.  

I've seen this similar error before when there is no mysql-server running, but I assume the working SHOW DATABASES proves there is a mysql server running?  

Cheers for any help.


Answers:
author: AS
body: Ok, I missed one variable from the ansible docks that helped here:

login_host: default is localhost

```

- name: add dev user to database
mysql_user: 
  name: '{{backend_database.user}}'
  password: '{{backend_database.pass}}'
  login_host: '{{backend_database.address}}'
  host: '{{backend_database.address}}'
  priv: '*.*:ALL'
  state: present
become: true
```

Hopefully this helps others coming up against the socket error.


Tags: ansible

bitbucket-cloud

cloud

mysql
Use custom variables in azure-aks-deploy pipe
Asked by Massimo Martini:

I'm using a step like this:

```
- pipe: microsoft/azure-aks-deploy:1.0.1
  variables:
    AZURE_APP_ID: $AZURE_APP_ID
    AZURE_PASSWORD: $AZURE_PASSWORD
    AZURE_TENANT_ID: $AZURE_TENANT_ID
    AZURE_AKS_NAME: $AKS_DEV_CLUSTER
    AZURE_RESOURCE_GROUP: $RESOURCE_GROUP
    KUBECTL_COMMAND: 'apply'
    KUBECTL_ARGUMENTS: '-f deployment/develop/secret.yml'
```

How can I use $MY_ENV_VARIABLE to replace a sensitive data inside secret.yml?

Thanks,

Massimo


Answers:
author: Massimo Martini
body: I solved by a simple SED command before the step ;-)

Thanks


Tags: bitbucket-pipelines

cloud

variable
is there any rest API in bitbucket which can download the file at particular commit?
Asked by Nikhil Jagga:

With below-mentioned API

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.\*}?at={commitId}

But with this API for binary files, we get this response

    {    "binary": true,    "path": {        "components": [            "src",            "log-output.7z"        ],        "parent": "src",        "name": "log-output.7z",        "extension": "7z",        "toString": "src/log-output.7z"    }}

For text files, we get this response

    {    "lines": [        {            "text": "abcd"        }    ],    "start": 0,    "size": 1,    "isLastPage": true}

I can re-create files with API response for text but is there any way to download the binary file or to get their size?


Answers:
author: Christian Glockner
body: Hi Nikhil,

I haven't tested this, but you may be able to get the file itself using this endpoint: <https://docs.atlassian.com/bitbucket-server/rest/7.7.1/bitbucket-rest.html#idp358>

Cheers,

Christian

Premier Support Engineer

Atlassian

comments: author: Nikhil Jagga
body: Hi [Christian Glockner](https://community.atlassian.com/t5/user/viewprofilepage/user-id/527595),  
Thanks, I have tested this API, I am able to get the file but for binary files, I am not getting the accurate size, is it the expected behavior?  

Can you please help me out with the following queries as well?  

1. <https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-Server-API-to-get-previous-commit-or-all-the-commits/qaq-p/1526272>  

2. <https://community.atlassian.com/t5/Bitbucket-questions/is-there-any-BB-Server-API-to-get-Merge-Strategy-used-for-a-pull/qaq-p/1527529#M59250>


Tags: bitbucket-server

server
Resetting Admin Password
Asked by Kelly Romeo:

Hello,

I am having an issue with accessing the admin account on a self-hosted Bitbucket server. I tried resetting account through the guide from this link. "<https://confluence.atlassian.com/bitbucketserver/lockout-recovery-process-776640158.html>" However, I still was not able access the recovery admin account to reset the password. Also, the server does not have an email server set up. Do you have any suggestions on how I can reset the password for the Admin account?

Thank you,


Answers:
author: Daniel Ebers
body: Hi Kelly,

welcome to the Atlassian Community!

At which stage of the lockout recovery process document you got stuck? Probably somebody can help here on Community in case you could explain further the current status, please.

Cheers,  
Daniel


Tags: bitbucket-server

server
Identical yaml file working in one repo and not in another
Asked by Esther Strom:

One of our devs came to me with an issue that I'm unable to solve. They have a yaml file that works perfectly in one repo, but errors out on another. I've checked all of the other settings at the repo level and they're all identical from one to the other.

Here's the bitbucket-pipelines.yaml file; I've downloaded the raw file from both repos and run them through a diff app to make sure they're identical, and they are.

```
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.3

pipelines: 
  default: 
    - step: 
      caches: 
       - composer 
  script: 
    - php -v 
    - apt-get update && apt-get install -y unzip 
    - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 
    - composer install 
    - vendor/bin/phpunit --bootstrap Tests/bootstrap.php Tests/
```

The error we're seeing in the repo where it doesn't work; the obfuscated areas are our repo names (which contain company-ID info), not linux package names.  
![2020-11-05 12_55_50-phconnectchicago _ login_authentication_service_php _ Pipelines ? Bitbucket.png](https://community.atlassian.com/t5/image/serverpage/image-id/117279iF5D2C2AC3EC4C27E/image-size/large?v=v2&px=999 "2020-11-05 12_55_50-phconnectchicago _ login_authentication_service_php _ Pipelines ? Bitbucket.png")

And when I downloaded the raw error file, the difference is this:  

![2020-11-05 12_59_49-pipelineLog-2.txt, pipelineLog-150.txt - SourceGear DiffMerge.png](/t5/image/serverpage/image-id/117273i79A8BE0A548EB7EC/image-size/large?v=v2&px=999 "2020-11-05 12_59_49-pipelineLog-2.txt, pipelineLog-150.txt - SourceGear DiffMerge.png")

Any ideas?


Answers:
author: Theodora Boudale
body: Hi Esther,

I'm not very familiar with composer, but based on the output, it looks that composer is trying to download dependencies using Git, but Git is not installed in the image you are using.

The other repo where the build works may download different dependencies. The dependencies are specified in the composer.json file and that file may be different for each repo.

If you need to clone private Git repositories in your build via composer, then I believe that you will need to install Git before the 'composer install' command (since the image doesn't have Git) and you'll also need to configure authentication, you can check here for details:

* <https://bitbucket.org/blog/cloning-another-bitbucket-repository-in-bitbucket-pipelines>

Kind regards,  
Theodora

comments: author: Esther Strom
body: Thanks, Teodora. I'll pass this info on to our devs. I did take a look at the composer.json files and they are quite different.


Tags: bitbucket-pipelines
How can we reduce the size of repo >2gb
Asked by Vijaya Ragavan Myeilswamy:

remote: Learn how to reduce your repository size: <https://confluence.atlassian.com/x/xgMvEw>.  
To <https://bitbucket.org/carters-ondemand/ecomm-automation.git>  
! \[remote rejected\] carters -\> carters (pre-receive hook declined)  
! \[remote rejected\] development -\> development (pre-receive hook declined)  
error: failed to push some refs to '<https://bitbucket.org/carters-ondemand/ecomm-automation.git>'

We also tried deleting all branches and files and now the repo has only the master branch with .gitignore. but till it is showing 2gb data.


Answers:
author: Theodora Boudale
body: Hi Vijaya,

If a repo's size is above 2 GB (and below 5 GB), then you can remove the read-only limitation by following the steps listed in "Undoing the last push" in the following doc:

* <https://support.atlassian.com/bitbucket-cloud/docs/reduce-repository-size/#Reducerepositorysize-Undoingthelastpush>

If you enable the Labs feature "Delete dangling commits when over size limit" and then rewind history to undo large commits, a git gc should be triggered automatically. Otherwise, you'll need to [create a support ticket](https://support.atlassian.com/contact/#/) and request a git gc for the repo after you rewind history and push.

If a repo is over 5 GB, the steps above will not work and a support ticket will be needed to get help with this issue.

I see that you have already opened a ticket for this, if you need anything further feel free to let us know.

Kind regards,  
Theodora


author: Mikael Sandberg
body: Hi [@Vijaya Ragavan Myeilswamy](/t5/user/viewprofilepage/user-id/4150957),

Welcome to Atlassian Community!

Removing branches (they are just pointers to commits) and files does not effect the size of the Git repository, you are just adding new commits to the history. You need to undo you last commit in order to get under 2Gb by undoing the push. Have a look at this [KB](https://support.atlassian.com/bitbucket-cloud/docs/reduce-repository-size/) on how to do that. You should also take a look at this one about [splitting your repository in two](https://support.atlassian.com/bitbucket-cloud/docs/split-a-repository-in-two/).


Tags: bitbucket-cloud

cloud
ScriptRunner Console Logging Level?
Asked by PeteToscano:

Hello,

I'm trying to do some automate some admin work that I need to be very careful with before I do it. I've had much luck with doing some automation with ScriptRunner for Jira Server (SRfJS), so I figured this would be a good thing to try to do with the Bitbucket Server (SRfBS) variant. My problem (well, this specific problem..) is related to logging.

Both versions have an injected log object. In SRfJS, I used log.setLevel(Level.INFO) when I wanted to see INFO-level messages and set the level higher when I didn't. In SRfBS, it seems that WARN is the floor for log4j levels, even when using log.setLevel(Level.ALL). This isn't the end of the world as I can convert my INFO messages to WARN, but it bothers me aesthetically. :D

Am I missing something?


Answers:
author: Max Lim _Adaptavist_
body: Interesting. It is different to SR4J.

I have tested following snippet in ScriptRunner \> Console, you can use Bitbucket's Java API to set the level like so:

```
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.log.LoggingService

def loggingService = ComponentLocator.getComponent(LoggingService)
loggingService.setLevel("com.onresolve.scriptrunner.runner.ScriptBindingsManager", "INFO")
log.info "SOmethissng"
```

You can read more about LoggingService class [here](https://docs.atlassian.com/bitbucket-server/javadoc/7.19.1/api/com/atlassian/bitbucket/log/LoggingService.html).

comments: author: PeteToscano
body: Thank you, Max. I'll keep this in mind the next time that I need to venture into SRfBS scripting.


Tags: adaptavist

bitbucket-server

log

scriptrunner

server
Workspace ID unavailable
Asked by Steve Oliver:

I have two bitbucket accounts. in account A I have created a workspace with and ID of 'my-id'. I want to use that ID for a workspace in account B. I have changed the workspace ID in account A to 'new-id'. When I try to change the workspace ID in account B to be 'my-id', I get an error saying the ID is not available.

Is the ID 'my-id' permanently unavailable to account B now because I used it previously in account A?


Answers:
author: Theodora Boudale
body: Hello,

Is the username of account A still 'my-id'? If so, this is the reason why 'my-id' cannot be used as a workspace ID in account B.

In order for someone to be able to use a workspace ID, it should not be in use already by either another workspace or by a username of a different account.

If you log in to account A, then go to your avatar (bottom left corner) \> **Personal settings**, you'll find the option to change the username of account A. When you do, 'my-id' should become available again.

Please feel free to let me know if this works for you and if you need anything further.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud