Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-12782

Pipelines. Allow to deploy files to Downloads section.

    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      With the arrival of "Pipelines" it's kind of a natural step to allow an API or artifact to deploy files build inside Pipelines to the "Downloads" section of bitbucket.

      Regards

            [BCLOUD-12782] Pipelines. Allow to deploy files to Downloads section.

            We've just released an experimental wagon for maven which deploys directly do bitbucket downloads - https://bitbucket.org/codedoers/maven-bitbucket-download-wagon

            it does the same as curl but treats the bitbucket downloads as a maven repository

            Piotr Bojko added a comment - We've just released an experimental wagon for maven which deploys directly do bitbucket downloads - https://bitbucket.org/codedoers/maven-bitbucket-download-wagon it does the same as curl but treats the bitbucket downloads as a maven repository

            Matt Ryall added a comment -

            Ah, thanks for letting me know, @zardify. I'll update the documentation to clarify that environment variables are only loaded from the account that owns the repository with the pipeline (usually a team), not an individual's account.

            Matt Ryall added a comment - Ah, thanks for letting me know, @zardify. I'll update the documentation to clarify that environment variables are only loaded from the account that owns the repository with the pipeline (usually a team), not an individual's account.

            zardify added a comment -

            I also struggled with this. The docs say you could put the environment variable in the User's bitbucket settings. I had it there, and got the same problems. (as Shota) because it didn't find it. Now that I put it in the repo's environment it's working finally... RIP 40 minutes.

            "You can define this environment variable at either the repository or account level. The example below is shown with an account environment variable."
            https://confluence.atlassian.com/bitbucket/deploy-build-artifacts-to-bitbucket-downloads-872124574.html(Link URL)

            zardify added a comment - I also struggled with this. The docs say you could put the environment variable in the User's bitbucket settings. I had it there, and got the same problems. (as Shota) because it didn't find it. Now that I put it in the repo's environment it's working finally... RIP 40 minutes. "You can define this environment variable at either the repository or account level. The example below is shown with an account environment variable." https://confluence.atlassian.com/bitbucket/deploy-build-artifacts-to-bitbucket-downloads-872124574.html (Link URL)

            Matt,

            Thank you for help. I can upload assets via pipeline.

            Shota Aratono added a comment - Matt, Thank you for help. I can upload assets via pipeline.

            Your assessment is correct, Shota. The BB_AUTH_STRING value comes from an environment variable in your Pipelines configuration, found under Settings > Environment Variables in your repository. For curl to authenticate, in the form <username>:<password>, e.g. s-aratono: 4GvSjtfuEW2Za7eAQzpu.

            Matt Ryall added a comment - Your assessment is correct, Shota. The BB_AUTH_STRING value comes from an environment variable in your Pipelines configuration, found under Settings > Environment Variables in your repository. For curl to authenticate, in the form <username>:<password> , e.g. s-aratono: 4GvSjtfuEW2Za7eAQzpu .

            Same issue. Here is a part log of pipeline.
            Before executing curl, I set variables by export BUILD_DATE=date "+%Y%m%d%H%M%S" and creating tar.gz file.

            Since there was message Enter host password for user '': in log, it seems that the BB_AUTH_STRING was not set.

            
            + curl -v -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${BITBUCKET_REPO_SLUG}-${BUILD_DATE}.tar.gz"
            Enter host password for user &#x27;&#x27;:
            * Hostname was NOT found in DNS cache
              % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                             Dload  Upload   Total   Spent    Left  Speed
              0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 104.192.143.4...
            * Connected to api.bitbucket.org (104.192.143.4) port 443 (#0)
            * successfully set certificate verify locations:
            *   CAfile: none
              CApath: /etc/ssl/certs
            * SSLv3, TLS handshake, Client hello (1):
            } [data not shown]
            * SSLv3, TLS handshake, Server hello (2):
            { [data not shown]
            * SSLv3, TLS handshake, CERT (11):
            { [data not shown]
            * SSLv3, TLS handshake, Server key exchange (12):
            { [data not shown]
            * SSLv3, TLS handshake, Server finished (14):
            { [data not shown]
            * SSLv3, TLS handshake, Client key exchange (16):
            } [data not shown]
            * SSLv3, TLS change cipher, Client hello (1):
            } [data not shown]
            * SSLv3, TLS handshake, Finished (20):
            } [data not shown]
            * SSLv3, TLS change cipher, Client hello (1):
            { [data not shown]
            * SSLv3, TLS handshake, Finished (20):
            { [data not shown]
            * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
            * Server certificate:
            * 	 subject: C=US; ST=CA; L=San Francisco; O=Atlassian, Inc.; OU=Bitbucket; CN=*.bitbucket.org
            * 	 start date: 2017-04-04 00:00:00 GMT
            * 	 expire date: 2020-06-11 12:00:00 GMT
            * 	 subjectAltName: api.bitbucket.org matched
            * 	 issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
            * 	 SSL certificate verify ok.
            * Server auth using Basic with user &#x27;&#x27;
            > POST /2.0/repositories/creationline/isoroku2_kakin_monthly/downloads HTTP/1.1
            > Authorization: Basic Og==
            > User-Agent: curl/7.38.0
            > Host: api.bitbucket.org
            > Accept: */*
            > Content-Length: 53258995
            > Expect: 100-continue
            > Content-Type: multipart/form-data; boundary=------------------------717e66d81aef3ecf
            > 
            < HTTP/1.1 100 Continue
            } [data not shown]
             94 50.7M    0     0   94 47.8M      0  92.6M --:--:-- --:--:-- --:--:-- 92.6M< HTTP/1.1 401 Unauthorized
            * Server nginx is not blacklisted
            < Server: nginx
            * Authentication problem. Ignoring this.
            < WWW-Authenticate: Basic realm="Bitbucket.org HTTP"
            < Content-Type: text/html; charset=utf-8
            < Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
            < Date: Thu, 11 May 2017 13:21:48 GMT
            < X-Served-By: app-161
            < X-Static-Version: c163c2069965
            < ETag: "d41d8cd98f00b204e9800998ecf8427e"
            < X-Render-Time: 0.0189681053162
            < Connection: keep-alive
            < X-Version: c163c2069965
            < X-Request-Count: 453
            < X-Frame-Options: SAMEORIGIN
            < Content-Length: 0
            * HTTP error before end of send, stop sending
            < 
            100 50.7M    0     0  100 50.7M      0  84.2M --:--:-- --:--:-- --:--:-- 84.0M
            * Closing connection 0
            * SSLv3, TLS alert, Client hello (1):
            } [data not shown]
            
            

            Shota Aratono added a comment - Same issue. Here is a part log of pipeline. Before executing curl, I set variables by export BUILD_DATE= date "+%Y%m%d%H%M%S" and creating tar.gz file. Since there was message Enter host password for user '': in log, it seems that the BB_AUTH_STRING was not set.  + curl -v -X POST --user "${BB_AUTH_STRING}" "https: //api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@ "${BITBUCKET_REPO_SLUG}-${BUILD_DATE}.tar.gz" Enter host password for user &#x27;&#x27;: * Hostname was NOT found in DNS cache % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 104.192.143.4... * Connected to api.bitbucket.org (104.192.143.4) port 443 (#0) * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs * SSLv3, TLS handshake, Client hello (1): } [data not shown] * SSLv3, TLS handshake, Server hello (2): { [data not shown] * SSLv3, TLS handshake, CERT (11): { [data not shown] * SSLv3, TLS handshake, Server key exchange (12): { [data not shown] * SSLv3, TLS handshake, Server finished (14): { [data not shown] * SSLv3, TLS handshake, Client key exchange (16): } [data not shown] * SSLv3, TLS change cipher, Client hello (1): } [data not shown] * SSLv3, TLS handshake, Finished (20): } [data not shown] * SSLv3, TLS change cipher, Client hello (1): { [data not shown] * SSLv3, TLS handshake, Finished (20): { [data not shown] * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * Server certificate: * subject: C=US; ST=CA; L=San Francisco; O=Atlassian, Inc.; OU=Bitbucket; CN=*.bitbucket.org * start date: 2017-04-04 00:00:00 GMT * expire date: 2020-06-11 12:00:00 GMT * subjectAltName: api.bitbucket.org matched * issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA * SSL certificate verify ok. * Server auth using Basic with user &#x27;&#x27; > POST /2.0/repositories/creationline/isoroku2_kakin_monthly/downloads HTTP/1.1 > Authorization: Basic Og== > User-Agent: curl/7.38.0 > Host: api.bitbucket.org > Accept: */* > Content-Length: 53258995 > Expect: 100- continue > Content-Type: multipart/form-data; boundary=------------------------717e66d81aef3ecf > < HTTP/1.1 100 Continue } [data not shown] 94 50.7M 0 0 94 47.8M 0 92.6M --:--:-- --:--:-- --:--:-- 92.6M< HTTP/1.1 401 Unauthorized * Server nginx is not blacklisted < Server: nginx * Authentication problem. Ignoring this . < WWW-Authenticate: Basic realm= "Bitbucket.org HTTP" < Content-Type: text/html; charset=utf-8 < Strict-Transport-Security: max-age=31536000; includeSubDomains; preload < Date: Thu, 11 May 2017 13:21:48 GMT < X-Served-By: app-161 < X-Static-Version: c163c2069965 < ETag: "d41d8cd98f00b204e9800998ecf8427e" < X-Render-Time: 0.0189681053162 < Connection: keep-alive < X-Version: c163c2069965 < X-Request-Count: 453 < X-Frame-Options: SAMEORIGIN < Content-Length: 0 * HTTP error before end of send, stop sending < 100 50.7M 0 0 100 50.7M 0 84.2M --:--:-- --:--:-- --:--:-- 84.0M * Closing connection 0 * SSLv3, TLS alert, Client hello (1): } [data not shown]

            Davide - thanks for the suggestion, I've updated our documentation.

            Enrique - glad to hear, I'll close this ticket. While we would like to simplify common operations like this in the future, for now the Bitbucket API is the best way to manipulate data on the service from your Pipelines builds.

            Matt Ryall added a comment - Davide - thanks for the suggestion, I've updated our documentation. Enrique - glad to hear, I'll close this ticket. While we would like to simplify common operations like this in the future, for now the Bitbucket API is the best way to manipulate data on the service from your Pipelines builds.

            I'm doing this with my project and it works. I agree with Enrique that it could be more elegant, but it gets the job done.

            michaeljmuller added a comment - I'm doing this with my project and it works. I agree with Enrique that it could be more elegant, but it gets the job done.

            According to explanations, I considered the issue fixed. It could be improved, reworked, whatever, but the main objective can now be achieved.

            Thanks a lot for the effort to everyone!

            I've tested it, it's working!

            kikeenrique added a comment - According to explanations, I considered the issue fixed. It could be improved, reworked, whatever, but the main objective can now be achieved. Thanks a lot for the effort to everyone! I've tested it, it's working!

            I'm using something similar:

            #!bash
            curl --fail --user ${BB_AUTH_STRING} --form files=@"target/output.jar" https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads
            
            

            I prefer it because user it is passed on the http headers

            Davide Cavarretta added a comment - I'm using something similar: #!bash curl --fail --user ${BB_AUTH_STRING} --form files=@ "target/output.jar" https: //api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads I prefer it because user it is passed on the http headers

              Unassigned Unassigned
              bdfda7acaf15 kikeenrique
              Votes:
              5 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated:
                Resolved: