Merge pull request #28 from actions/add-bamboo-to-issue-ops

Add Bamboo support
This commit is contained in:
Chase S
2023-08-11 10:24:37 -05:00
committed by GitHub
11 changed files with 185 additions and 4 deletions

21
.github/ISSUE_TEMPLATE/bamboo.md vendored Normal file
View File

@@ -0,0 +1,21 @@
---
name: Bamboo
about: Migrate Bamboo pipelines to GitHub Actions
title: "[Bamboo]:"
labels: bamboo
assignees: ""
---
## Inputs
Plan Slug: _Replace this text with the Bamboo plan slug (e.g. PAN-SLUG) to migrate pipelines from._
## Available commands
The following commands can be executed by adding a comment to this issue:
- `/audit`
- `/dry-run --plan-type build|deployment`
- `/migrate --plan-type build|deployment --target-url :github-repository-url`
**Note:** The `plan-type` option will default to `build` if omitted. If any remaining options are missing, the command will not be successful.

View File

@@ -26,6 +26,8 @@ env:
GITLAB_INSTANCE_URL: ${{ secrets.gitlab_instance_url || 'https://gitlab.com' }}
CIRCLE_CI_ACCESS_TOKEN: ${{ secrets.circle_ci_access_token }}
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 }}
jobs:
execute-actions-importer:

View File

@@ -26,6 +26,7 @@ jobs:
'circle-ci',
'gitlab',
'travis-ci',
'bamboo',
'actions-importer-running'
];

View File

@@ -2,7 +2,7 @@
The GitHub Actions Importer IssueOps repository demonstrates the functionality necessary to run GitHub Actions Importer commands through Actions and Issues, allowing you to migrate your CI/CD workflows without needing to install software on your local machine. This approach is especially useful for organizations that want to enable self-service migrations to GitHub Actions.
[GitHub Actions Importer](https://docs.github.com/en/actions/migrating-to-github-actions/automating-migration-with-github-actions-importer) helps plan, forecast, and automate the migration of Azure DevOps, CircleCI, GitLab, Jenkins, and Travis CI pipelines to GitHub Actions. GitHub Actions Importer is distributed as a CLI and offers various commands you can use to migrate pipelines:
[GitHub Actions Importer](https://docs.github.com/en/actions/migrating-to-github-actions/automating-migration-with-github-actions-importer) helps plan, forecast, and automate the migration of Azure DevOps, Bamboo, CircleCI, GitLab, Jenkins, and Travis CI pipelines to GitHub Actions. GitHub Actions Importer is distributed as a CLI and offers various commands you can use to migrate pipelines:
- `audit`: An audit will fetch all the pipelines defined in an existing CI server, convert each pipeline to its equivalent in GitHub Actions, and write a report that summarizes how complete of a migration the GitHub Actions Importer can provide.
- `dry-run`: A dry run will fetch a single pipeline definition, convert it to its equivalent in GitHub Actions, and write a file (or files) to disk containing the converted workflow.
@@ -13,7 +13,7 @@ The GitHub Actions Importer IssueOps repository demonstrates the functionality n
Complete the following steps:
1. Create a new repository using this repository as the template by clicking [here](https://github.com/actions/importer-issue-ops/generate).
2. Create the following labels in this new repository, if they are not already present: `jenkins`, `azure-devops`, `circle-ci`, `gitlab`, `travis-ci`, and `actions-importer-running`.
2. Create the following labels in this new repository, if they are not already present: `jenkins`, `azure-devops`, `circle-ci`, `gitlab`, `travis-ci`, `bamboo`, and `actions-importer-running`.
3. Add the repository secrets described below that are relevant to the CI/CD providers being migrated.
### Repository settings
@@ -22,7 +22,7 @@ The repository that is created from this template must have one of the following
- Any action or reusable workflow can be used, regardless of who authored it or where it is defined.
- Any action or reusable workflow that matches the specified criteria, plus those defined in a repository within the enterprise, can be used.
- Allow actions created by GitHub
- Allow actions created by GitHub
- Allow actions by marketplace verified creators or icnlude `ruby/setup-ruby@v1` in the allowed list of actions and reusable workflows.
See the [documentation](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#managing-github-actions-permissions-for-your-repository) for more information related to these settings.
@@ -95,6 +95,13 @@ Optionally, the following secrets can be set:
- `TRAVIS_CI_INSTANCE_URL`: The base URL of your Travis CI instance (only required if it is **not** <https://travis-ci.com>).
### Bamboo
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.
## Pipeline migration
Once configured, pipelines can be migrated to GitHub Actions by opening an issue with the relevant issue template and following the instructions.

View File

@@ -0,0 +1,18 @@
# frozen_string_literal: true
module Bamboo
class Audit
include IssueParser
def initialize(issue_content, _)
@project = parameter_from_issue("Project", issue_content)
end
def to_a
args = []
args.push(["--project", @project]) unless @project.nil?
return args unless args.empty?
end
end
end

View File

@@ -0,0 +1,20 @@
# frozen_string_literal: true
module Bamboo
class DryRun
include IssueParser
def initialize(issue_content, command)
@plan_slug = parameter_from_issue("Plan Slug", issue_content)
@plan_type = command.options.fetch("plan-type", "build")
end
def to_a
args = [@plan_type]
args.push(["--plan-slug", @plan_slug]) unless @plan_slug.nil?
return args unless args.empty?
end
end
end

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
module Bamboo
class Migrate
include IssueParser
def initialize(issue_content, command)
@plan_slug = parameter_from_issue("Plan Slug", issue_content)
@plan_type = command.options.fetch("plan-type", "build")
@target_url = command.options["target-url"]
end
def to_a
args = [@plan_type]
args.push(["--plan-slug", @plan_slug]) unless @plan_slug.nil?
args.push(["--target-url", @target_url]) unless @target_url.nil?
return args unless args.empty?
end
end
end

View File

@@ -14,7 +14,8 @@ class Provider
"circle-ci" => ::CircleCI,
"gitlab" => ::GitlabCI,
"jenkins" => ::Jenkins,
"travis-ci" => ::TravisCI
"travis-ci" => ::TravisCI,
"bamboo" => ::Bamboo
}.freeze
def initialize(labels)

View File

@@ -0,0 +1,29 @@
# frozen_string_literal: true
RSpec.describe Bamboo::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
Project:
ISSUE
end
it { is_expected.to be_nil }
end
context "when issue_content contains a project" do
let(:issue_content) do
<<~ISSUE
Project: Demo
ISSUE
end
it { is_expected.to eq([["--project", "Demo"]]) }
end
end
end

View File

@@ -0,0 +1,27 @@
# frozen_string_literal: true
RSpec.describe Bamboo::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
Plan Slug: PAN-PLAN
ISSUE
end
context "when the comment body does not contain a plan type" do
let(:comment_body) { "/dry-run" }
it { is_expected.to eq(["build", ["--plan-slug", "PAN-PLAN"]]) }
end
context "when the comment body contains a plan type" do
let(:comment_body) { "/dry-run --plan-type deployment" }
it { is_expected.to eq(["deployment", ["--plan-slug", "PAN-PLAN"]]) }
end
end
end

View File

@@ -0,0 +1,33 @@
# frozen_string_literal: true
RSpec.describe Bamboo::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
Plan Slug: PAN-PLAN
ISSUE
end
context "when the comment body does not contain a pipeline type" do
let(:comment_body) { "/migrate" }
it { is_expected.to eq(["build", ["--plan-slug", "PAN-PLAN"]]) }
end
context "when the comment body contains a plan type" do
let(:comment_body) { "/dry-run --plan-type deployment" }
it { is_expected.to eq(["deployment", ["--plan-slug", "PAN-PLAN"]]) }
end
context "with a target-url" do
let(:comment_body) { "/migrate --target-url https://github.com/valet" }
it { is_expected.to eq(["build", ["--plan-slug", "PAN-PLAN"], ["--target-url", "https://github.com/valet"]]) }
end
end
end