I want to keep different build versions in my download page on Bitbucket. So I tried to format the output of my build like the following:
curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"build-${BITBUCKET_BUILD_NUMBER}/${DOCUMENT_NAME}.pdf"
But the build, which ran sucessfuly before, failes now. Even I change the / to an _ the build fails.
Found the answer: The build script produces a file named ausarbeitung.pdf. Before uploading to Downloads you have to rename the file:
- mv "ausarbeitung.pdf" "${DOCUMENT_NAME}-V${BITBUCKET_BUILD_NUMBER}.pdf"
After that you can upload the file to Downloads:
- curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${DOCUMENT_NAME}-V${BITBUCKET_BUILD_NUMBER}.pdf"
Hi @ericfischerbav,
unfortunately Bitbucket Downloads does not support directories at the moment. You can open a feature request here: https://bitbucket.org/site/master/issues?status=new&status=open
Alternatively, you can just include the build number in the name of your artefact?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jeroen De Raedt,
thanks for your answer.
I'll request this feature, can be useful.
However, even if I try to include the version into the artifact, the build fails. The error message is: "File not found." I have the same problem with another repo and the same access token, here no output is created. Are there some restricted characters in Bitbucket Downloads?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
File not found probably means that the file you reference from your local directory does not exist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I looked it up the error is exactly: 'couldn't open file ...'
So I tried to insert a different name in the environment variables. Same issue here. It seems the pipeline can only write into the existing PDF file in Downloads.
This is the log of the last build. I removed all the LaTeX log (this works...)
+ umask 000
+ GIT_LFS_SKIP_SMUDGE=1 git clone --branch="master" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/projectteamdhbw/schriftliche-ausarbeitung-projekt.git $BUILD_DIR ; git reset --hard a515e3ff4a7b7760921fc245b476c97a6d41445d ; git remote set-url origin git@bitbucket.org:projectteamdhbw/schriftliche-ausarbeitung-projekt.git
Cloning into '/opt/atlassian/pipelines/agent/build'...
HEAD is now at a515e3f README.md edited online with Bitbucket
+ chmod 777 $BUILD_DIR
+ pdflatex --shell-escape ausarbeitung.tex
[...]
Output written on ausarbeitung.pdf (10 pages, 63342 bytes).
Transcript written on ausarbeitung.log.
+ curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${DOCUMENT_NAME}.pdf"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (26) couldn't open file "JokaMenterSchunkFischer-Ausarbeitung.pdf"
Searching for test report files in directories named [test-results, failsafe-reports, test-reports, surefire-reports] down to a depth of 4
Finished scanning for test reports. Found 0 test report files.
Merged test suites, total number tests is 0, with 0 failures and 0 errors.
And here's my bitbucket-pipelines.yml:
ptions: docker: true image: kaspersoerensen/latex-docker pipelines: branches: master: - step: script: - pdflatex --shell-escape ausarbeitung.tex # Build once - bibtex ausarbeitung # Build bibtex - pdflatex -shell-escape ausarbeitung.tex # Build again - pdflatex -shell-escape ausarbeitung.tex # And last time - curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${DOCUMENT_NAME}.pdf" definitions: caches: bundler: kaspersoerensen/latex-docker
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.