Add Bitbucket support

This commit is contained in:
chaseshak
2023-08-10 11:08:04 -05:00
parent 65b029a677
commit d9b386d83b
10 changed files with 160 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
---
name: Bitbucket
about: Migrate Bitbucket pipelines to GitHub Actions
title: "[Bitbucket]:"
labels: bitbucket
assignees: ""
---
## Inputs
Provide the following required inputs:
Workspace: _Replace this text with the Bitbucket Workspace to migrate pipelines from._
## Available commands
The following commands can be executed by adding a comment to this issue:
- `/audit`
- `/dry-run --repository :repository-name`
- `/migrate --repository :repository-name --target-url :github-repository-url`
+1
View File
@@ -28,6 +28,7 @@ env:
CIRCLE_CI_SOURCE_GITHUB_ACCESS_TOKEN: ${{ secrets.circle_ci_source_github_access_token }}
BAMBOO_ACCESS_TOKEN: ${{ secrets.bamboo_access_token }}
BAMBOO_INSTANCE_URL: ${{ secrets.bamboo_instance_url }}
BITBUCKET_ACCESS_TOKEN: ${{ secrets.bitbucket_access_token }}
jobs:
execute-actions-importer:
+5
View File
@@ -101,6 +101,11 @@ The following secrets are required:
- `BAMBOO_ACCESS_TOKEN`: The personal access token to access the Bamboo instance.
- `BAMBOO_INSTANCE_URL`: The base URL of your Bamboo instance.
### Bitbucket
The following secrets are required:
- `BITBUCKET_ACCESS_TOKEN`: The personal access token to access the BitBucket instance.
## Pipeline migration
+17
View File
@@ -0,0 +1,17 @@
# frozen_string_literal: true
module Bitbucket
class Audit
include IssueParser
def initialize(issue_content, _)
@workspace = parameter_from_issue("Workspace", issue_content)
end
def to_a
return if @workspace.nil?
[["--workspace", @workspace]]
end
end
end
+20
View File
@@ -0,0 +1,20 @@
# frozen_string_literal: true
module Bitbucket
class DryRun
include IssueParser
def initialize(issue_content, command)
@workspace = parameter_from_issue("Workspace", issue_content)
@repository = command.options["repository"]
end
def to_a
args = []
args.push(["--workspace", @workspace]) unless @workspace.nil?
args.push(["--repository", @repository]) unless @repository.nil?
return args unless args.empty?
end
end
end
+22
View File
@@ -0,0 +1,22 @@
# frozen_string_literal: true
module Bitbucket
class Migrate
include IssueParser
def initialize(issue_content, command)
@workspace = parameter_from_issue("Workspace", issue_content)
@repository = command.options["repository"]
@target_url = command.options["target-url"]
end
def to_a
args = []
args.push(["--workspace", @workspace]) unless @workspace.nil?
args.push(["--repository", @repository]) unless @repository.nil?
args.push(["--target-url", @target_url]) unless @target_url.nil?
return args unless args.empty?
end
end
end
+3 -2
View File
@@ -11,11 +11,12 @@ class Provider
PROVIDER_MAP = {
"azure-devops" => ::AzureDevops,
"bamboo" => ::Bamboo,
"bitbucket" => ::Bitbucket,
"circle-ci" => ::CircleCI,
"gitlab" => ::GitlabCI,
"jenkins" => ::Jenkins,
"travis-ci" => ::TravisCI,
"bamboo" => ::Bamboo
"travis-ci" => ::TravisCI
}.freeze
def initialize(labels)
+29
View File
@@ -0,0 +1,29 @@
# frozen_string_literal: true
RSpec.describe Bitbucket::Audit do
let(:audit) { described_class.new(issue_content, nil) }
describe "#to_a" do
subject { audit.to_a }
context "when issue_content contains no args" do
let(:issue_content) do
<<~ISSUE
Workspace:
ISSUE
end
it { is_expected.to be_nil }
end
context "when issue_content contains a organization" do
let(:issue_content) do
<<~ISSUE
Workspace: testing
ISSUE
end
it { is_expected.to eq([["--workspace", "testing"]]) }
end
end
end
+21
View File
@@ -0,0 +1,21 @@
# frozen_string_literal: true
RSpec.describe Bitbucket::DryRun do
let(:dry_run) { described_class.new(issue_content, command) }
let(:command) { Command.new(comment_body) }
describe "#to_a" do
subject { dry_run.to_a }
let(:issue_content) do
<<~ISSUE
Workspace: testing
ISSUE
end
context "when the comment body contains a repository" do
let(:comment_body) { "/dry-run --repository repo" }
it { is_expected.to eq([["--workspace", "testing"], ["--repository", "repo"]]) }
end
end
end
+21
View File
@@ -0,0 +1,21 @@
# frozen_string_literal: true
RSpec.describe Bitbucket::Migrate do
let(:dry_run) { described_class.new(issue_content, command) }
let(:command) { Command.new(comment_body) }
describe "#to_a" do
subject { dry_run.to_a }
let(:issue_content) do
<<~ISSUE
Workspace: testing
ISSUE
end
context "when the comment body contains a repository" do
let(:comment_body) { "/migrate --repository repo --target-url https://github.com/org/repo" }
it { is_expected.to eq([["--workspace", "testing"], ["--repository", "repo"], ["--target-url", "https://github.com/org/repo"]]) }
end
end
end