Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build agent for BitBucket Pipelines #3069

Merged

Conversation

davidkeaveny
Copy link
Contributor

@davidkeaveny davidkeaveny commented Apr 6, 2022

Description

Added a build agent that supports Atlassian's BitBucket Pipelines. It follows a similar pattern to the GitHub Actions build agent, in that it writes out the output from GitVersion to a file which can then be imported into Pipelines.

Related Issue

#3057

Motivation and Context

At present, GitVersion cannot generate version numbers when executed in BitBucket Pipelines on branches that are not develop or main\master (see related issue). By creating a specific build agent, I am hoping to fix this issue.

How Has This Been Tested?

I have created a set of unit tests in the GitVersion.Core.Tests project in the BuildAgents folder.

The build agent can be run from the command line by setting the environment variable BITBUCKET_WORKSPACE to any non-empty value, and BITBUCKET_BRANCH to the branch being built (these values are set automatically by the BitBucket Pipeline).

e.g.

set BITBUCKET_WORKSPACE=MyProject
set BITBUCKET_BRANCH=refs/head/feature/my-new-feature
gitversion.exe /diag

In addition to writing the output to the screen, a file gitversion.env will be created; in BitBucket Pipelines, this file would then be imported to add the new environment variables.

Testing on the build server will require a new NuGet package containing the updated GitVersion.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@arturcic
Copy link
Member

arturcic commented Apr 6, 2022

@davidkeaveny great that you add BitBucket Pipelines support, can you also add a test here https://github.com/GitTools/GitVersion/blob/support/5.x/src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs

@davidkeaveny
Copy link
Contributor Author

@arturcic I've added the test to the requested test fixture, and it passes (assuming I'm using it correctly!).

How would I go about doing an end-to-end test? With BitBucket Cloud, build steps run in containers, so I have to install GitVersion as a global tool before running it; I can't just copy a build from my local PC to an on-premise build server.

@arturcic
Copy link
Member

arturcic commented Apr 7, 2022

@davidkeaveny to have this PR ready to be merged we also need the docs to be updated - can you add a page here as well https://github.com/GitTools/GitVersion/tree/support/5.x/docs/input/docs/reference/build-servers ?

@arturcic
Copy link
Member

arturcic commented Apr 7, 2022

How would I go about doing an end-to-end test? With BitBucket Cloud, build steps run in containers, so I have to install GitVersion as a global tool before running it; I can't just copy a build from my local PC to an on-premise build server.

When this PR is merged we can prepare a new build as there are already some new code to be released

@davidkeaveny
Copy link
Contributor Author

I've added initial documentation for using the CLI tool; I haven't documented the use of the Docker image yet because I haven't had a chance to try it out yet.

@asbjornu
Copy link
Member

asbjornu commented Apr 8, 2022

@davidkeaveny, where we would like BitBucket Pipelines support documented is on Build Servers.

@arturcic arturcic force-pushed the feature/add-bitbucket-build-agent branch from 00261df to b6ccb39 Compare April 11, 2022 07:21
@davidkeaveny davidkeaveny requested a review from gep13 April 12, 2022 22:49
@davidkeaveny
Copy link
Contributor Author

Sorry @gep13 , I can't see what the requested change is.

@gep13
Copy link
Member

gep13 commented Apr 13, 2022

@davidkeaveny said...
Sorry @gep13 , I can't see what the requested change is.

The requested/suggested changes from me was the slight change to wording in the markdown file, and the removal of the RedirectFrom. Both of these look to have been taken care of.

The remaining item would be the decision between gitversion.env or gitversion.properties. @asbjornu @arturcic what are your thoughts on this?

@arturcic
Copy link
Member

@davidkeaveny said...
Sorry @gep13 , I can't see what the requested change is.

The requested/suggested changes from me was the slight change to wording in the markdown file, and the removal of the RedirectFrom. Both of these look to have been taken care of.

The remaining item would be the decision between gitversion.env or gitversion.properties. @asbjornu @arturcic what are your thoughts on this?

I would say gitversion.properties seems fine, and it's already changed to it. I think we can merge it.

@arturcic arturcic merged commit 54c1ed0 into GitTools:support/5.x Apr 13, 2022
@mergify
Copy link
Contributor

mergify bot commented Apr 13, 2022

Thank you @davidkeaveny for your contribution!

@arturcic arturcic linked an issue Apr 13, 2022 that may be closed by this pull request
arturcic pushed a commit that referenced this pull request Apr 13, 2022
Merge pull request #3069 from davidkeaveny/feature/add-bitbucket-build-agent

Add build agent for BitBucket Pipelines
@davidkeaveny
Copy link
Contributor Author

Is it possible to publish pre-release versions, so that I can test this on my BitBucket Pipelines? If not, is there any particular schedule that GitVersion is working on for a next release?

@davidkeaveny davidkeaveny deleted the feature/add-bitbucket-build-agent branch April 13, 2022 09:51
@arturcic
Copy link
Member

arturcic commented Apr 13, 2022

There are some PR @asbjornu is working on, so whenever he says he's done we can release.

@arturcic arturcic modified the milestones: 5.x, 5.10.0 Apr 14, 2022
@github-actions
Copy link

🎉 This issue has been resolved in version 5.10.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot generate version number on BitBucket Cloud Pipelines
4 participants