How to change the build number on a bitbucket repository pipeline located in a team, not a user.

Bo Lind Jensen August 8, 2019

Hi I am trying to change the build number on a Bitbucket pipeline.

The Repository is located under a Team Account and not under my Username Account.

I have followed the guide

"Set a new value for the Pipelines build number":
https://confluence.atlassian.com/bitbucket/set-a-new-value-for-the-pipelines-build-number-935380150.html

But without expected outcome  :(

I have setup my user account, with an app password, and can see that I get a "404 not found" error now, instead of a "401 Unauthorized". 

As can be seen underneath in the log extract, the 404 error seems like I am pointing towards the wrong repository location. 

 

So I was thinking of using the team name and create an App Password. but that is not possible.

"Bitbucket Settings -> ACCESS MANAGEMENT -> App Passwords" is only available for User Profiles and not Teams.

Teams only have OAuth.

 

How do I change the build number for a repository located in a Team, and not on a user like the above guide expects?

 

My best try:

$ curl -v -H 'Content-Type: application/json' -XPUT \
> -d '{"next": 9000}' \
> --user 'MY_USER_ACCOUNT:APP_PASSWORD_WITH_PIPELINE_ACCESS' \
> 'https://api.bitbucket.org/2.0/repositories/MY_USER_ACCOUNT/REPOSLUG/pipelines_config/build_number'


* Trying 18.205.93.6...
* TCP_NODELAY set
* Connected to api.bitbucket.org (18.205.93.6) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=Atlassian, Inc.; OU=Bitbucket; CN=*.bitbucket.org
* start date: Jun 12 00:00:00 2017 GMT
* expire date: Jun 16 12:00:00 2020 GMT
* subjectAltName: host "api.bitbucket.org" matched cert's "*.bitbucket.org"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Server auth using Basic with user 'MY_USER_ACCOUNT'
* Using Stream ID: 1 (easy handle 0x7fffe2bf08e0)
> PUT /2.0/repositories/MY_USER_ACCOUNT/REPOSLUG/pipelines_config/build_number HTTP/2
> Host: api.bitbucket.org
> Authorization: Basic YmxqX2FjdTpkRlhHZ1ozeWVFcU5EblJ2VkNNYg==
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 12
>
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2 404
< server: nginx
< content-type: application/json; charset=utf-8
< x-oauth-scopes: pipeline:variable
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< date: Thu, 08 Aug 2019 13:28:50 GMT
< x-served-by: app-140
< x-static-version: d7eafd731394
< etag: "d8570ff7a4314593e35e9bc69e81400a"
< x-credential-type: apppassword
< x-render-time: 0.0304181575775
< x-version: d7eafd731394
< x-frame-options: SAMEORIGIN
< x-reads-before-write-from: default
< x-request-count: 749
< content-length: 52
<
* Connection #0 to host api.bitbucket.org left intact

---------

 

 

 

1 answer

1 accepted

1 vote
Answer accepted
Bo Lind Jensen August 9, 2019

I figured it out, with the help of a friend :)
This might help somebody else. 

 

I was using my username, twice (as the guide highlighted). But I should have done was use my username once, and the repo "username" once.

What i did:
repositories/MY_USER_ACCOUNT/REPONAME

What I should have done:
repositories/TEAM_USER_NAME/REPONAME

like this

 curl -v -H 'Content-Type: application/json' -XPUT \
> -d '{"next": 9001}' \
> --user 'MY_USER_ACCOUNT:APP_PASSWORD_WITH_PIPELINE_ACCESS' \
> 'https://api.bitbucket.org/2.0/repositories/TEAM_USER_NAME/REPOSLUG/pipelines_config/build_number'

 

Hope it helps somebody else :)

Martin Bielmann June 25, 2020

Note 1: My repository name contained one upper-case letter. In the URL, I had to write it lower-case, to make the PUT return a 200. 

Note 2: What you call "TEAM" is now called WORKSPACE.

I hope it helps.

Balázs Rozsenich December 22, 2020

Yeah, that's why they write repo slug: https://support.atlassian.com/bitbucket-cloud/docs/what-is-a-slug/

However, as not a native speaker, this wiki was very helpful.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events