Skip to content

Commit

Permalink
Merge pull request #235 from github/add-bb-commands
Browse files Browse the repository at this point in the history
Add Bitbucket commands
  • Loading branch information
begonaguereca committed Sep 12, 2023
2 parents b36e329 + 587e99d commit 4b1f8af
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 12 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[GitHub Actions Importer](https://docs.github.com/en/actions/migrating-to-github-actions/automating-migration-with-github-actions-importer) helps plan, test, and automate your migration to GitHub Actions from the following platforms:

- Azure DevOps
- Bamboo (currently in beta)
- Bamboo
- Bitbucket
- CircleCI
- GitLab
- Jenkins
Expand All @@ -15,7 +16,7 @@

If you need assistance, you can file a support ticket [here](https://support.github.com).

## Getting started
## Getting started

GitHub Actions Importer is distributed as a Docker container and this extension to the official [GitHub CLI](https://cli.github.com) to interact with the Docker container.

Expand All @@ -32,15 +33,15 @@ The following requirements must be met to be able to use the GitHub Actions Impo
Next, the GitHub Actions Importer CLI extension can be installed via this command:

```bash
$ gh extension install github/gh-actions-importer
gh extension install github/gh-actions-importer
```

### Configuration

New versions of the GitHub Actions Importer are released on a regular basis. To ensure you're up to date, run the following command:

```bash
$ gh actions-importer update
gh actions-importer update
```

In order for GitHub Actions Importer to communicate with your current CI/CD server and GitHub, various credentials must be available for the command. These can be configured using environment variables or a `.env.local` file. These environment variables can be configured in an interactive prompt by running the following command:
Expand All @@ -60,11 +61,12 @@ Detailed information about how to use GitHub Actions Importer can be found in th
### Recordings

You can access recorded demos of GitHub Actions Importer performing migrations to Actions from the following CI/CD platforms:
- [Azure DevOps](https://youtu.be/gG-2bkmBRlI)
- [CircleCI](https://youtu.be/YkFnNEyM9Hg)
- [GitLab](https://youtu.be/3t5ywu0_qk4)
- [Jenkins](https://youtu.be/WqiGP6h4fa0)
- [Travis CI](https://youtu.be/ndc-FNa_X3c)

- [Azure DevOps](https://youtu.be/gG-2bkmBRlI)
- [CircleCI](https://youtu.be/YkFnNEyM9Hg)
- [GitLab](https://youtu.be/3t5ywu0_qk4)
- [Jenkins](https://youtu.be/WqiGP6h4fa0)
- [Travis CI](https://youtu.be/ndc-FNa_X3c)

### Self-guided learning

Expand Down
2 changes: 1 addition & 1 deletion docs/jenkins/SCPPublish.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
scp scp_transfer.tar 127.0.0.1:
ssh 127.0.0.1 'tar -xvf scp_transfer.tar -C /results && rm scp_transfer.tar'
```

### Unsupported Options

- Keeps Hierarchy (currrently always keeps folder structure)

1 change: 1 addition & 0 deletions src/ActionsImporter.UnitTests/Models/VariableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class VariableTests
[TestCase(Provider.Jenkins, "Jenkins")]
[TestCase(Provider.TravisCI, "Travis CI")]
[TestCase(Provider.Bamboo, "Bamboo")]
[TestCase(Provider.Bitbucket, "Bitbucket")]
public void ProviderName_ValidName_ReturnsExpected(Provider provider, string providerName)
{
// Arrange
Expand Down
1 change: 1 addition & 0 deletions src/ActionsImporter/Commands/Audit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected override Command GenerateCommand(App app)
command.AddGlobalOption(FoldersOption);
command.AddCommand(new AzureDevOps.Audit(_args).Command(app));
command.AddCommand(new Bamboo.Audit(_args).Command(app));
command.AddCommand(new Bitbucket.Audit(_args).Command(app));
command.AddCommand(new Circle.Audit(_args).Command(app));
command.AddCommand(new GitLab.Audit(_args).Command(app));
command.AddCommand(new Jenkins.Audit(_args).Command(app));
Expand Down
20 changes: 20 additions & 0 deletions src/ActionsImporter/Commands/Bitbucket/Audit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Collections.Immutable;
using System.CommandLine;

namespace ActionsImporter.Commands.Bitbucket;

public class Audit : ContainerCommand
{
public Audit(string[] args) : base(args)
{
}

protected override string Name => "bitbucket";
protected override string Description => "An audit will output a list of data used in a Bitbucket instance.";
protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>(
Common.AccessToken,
Common.Workspace,
Common.Project,
Common.ConfigFilePath
);
}
44 changes: 44 additions & 0 deletions src/ActionsImporter/Commands/Bitbucket/Common.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.CommandLine;

namespace ActionsImporter.Commands.Bitbucket;

public static class Common
{


public static readonly Option<string> AccessToken = new("--bitbucket-access-token")
{
Description = "Access token for the Bitbucket instance.",
IsRequired = false,
};

public static readonly Option<string> Workspace = new(new[] { "--workspace", "-w" })
{
Description = "The Bitbucket workspace name.",
IsRequired = true,
};

public static readonly Option<string> Project = new(new[] { "--project-key", "-p" })
{
Description = "The Bitbucket project key.",
IsRequired = false,
};

public static readonly Option<string> Repository = new(new[] { "--repository", "-r" })
{
Description = "The Bitbucket repository name.",
IsRequired = true,
};

public static readonly Option<FileInfo> ConfigFilePath = new("--config-file-path")
{
Description = "The file path to the GitHub Actions Importer configuration file.",
IsRequired = false,
};

public static readonly Option<FileInfo> SourceFilePath = new("--source-file-path")
{
Description = "The file path corresponding to the Bamboo pipeline file.",
IsRequired = false,
};
}
22 changes: 22 additions & 0 deletions src/ActionsImporter/Commands/Bitbucket/DryRun.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Immutable;
using System.CommandLine;

namespace ActionsImporter.Commands.Bitbucket;

public class DryRun : ContainerCommand
{
public DryRun(string[] args) : base(args)
{
}

protected override string Name => "bitbucket";
protected override string Description => "Convert a Bitbucket pipeline to a GitHub Actions workflow and output the yaml file.";

protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>(
Common.Workspace,
Common.Repository,
Common.AccessToken,
Common.SourceFilePath,
Common.ConfigFilePath
);
}
35 changes: 35 additions & 0 deletions src/ActionsImporter/Commands/Bitbucket/Forecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Immutable;
using System.CommandLine;

namespace ActionsImporter.Commands.Bitbucket;

public class Forecast : ContainerCommand
{
public Forecast(string[] args) : base(args)
{
}

protected override string Name => "bitbucket";
protected override string Description => "Forecasts GitHub Actions usage from historical Bitbucket pipeline utilization.";

private static readonly Option<FileInfo[]> SourceFilePath = new("--source-file-path")
{
Description = "The file path(s) to existing jobs data.",
IsRequired = false,
AllowMultipleArgumentsPerToken = true,
};

private static readonly Option<FileInfo> IncludeFrom = new("--include-from")
{
Description = "The file path containing a list of line-delimited repository names to include in the forecast.",
IsRequired = false,
};

protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>(
Common.Project,
Common.Workspace,
Common.AccessToken,
SourceFilePath,
IncludeFrom
);
}
22 changes: 22 additions & 0 deletions src/ActionsImporter/Commands/Bitbucket/Migrate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Immutable;
using System.CommandLine;

namespace ActionsImporter.Commands.Bitbucket;

public class Migrate : ContainerCommand
{
public Migrate(string[] args) : base(args)
{
}

protected override string Name => "bitbucket";
protected override string Description => "Convert a Bitbucket pipeline to a GitHub Actions workflow and open a pull request with the changes.";

protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>(
Common.Workspace,
Common.Repository,
Common.AccessToken,
Common.SourceFilePath,
Common.ConfigFilePath
);
}
1 change: 1 addition & 0 deletions src/ActionsImporter/Commands/DryRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected override Command GenerateCommand(App app)

command.AddCommand(new AzureDevOps.DryRun(_args).Command(app));
command.AddCommand(new Bamboo.DryRun(_args).Command(app));
command.AddCommand(new Bitbucket.DryRun(_args).Command(app));
command.AddCommand(new Circle.DryRun(_args).Command(app));
command.AddCommand(new GitLab.DryRun(_args).Command(app));
command.AddCommand(new Jenkins.DryRun(_args).Command(app));
Expand Down
1 change: 1 addition & 0 deletions src/ActionsImporter/Commands/Forecast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected override Command GenerateCommand(App app)
command.AddCommand(new Travis.Forecast(_args).Command(app));
command.AddCommand(new GitHub.Forecast(_args).Command(app));
command.AddCommand(new Bamboo.Forecast(_args).Command(app));
command.AddCommand(new Bitbucket.Forecast(_args).Command(app));

return command;
}
Expand Down
1 change: 1 addition & 0 deletions src/ActionsImporter/Commands/Migrate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected override Command GenerateCommand(App app)

command.AddCommand(new AzureDevOps.Migrate(_args).Command(app));
command.AddCommand(new Bamboo.Migrate(_args).Command(app));
command.AddCommand(new Bitbucket.Migrate(_args).Command(app));
command.AddCommand(new Circle.Migrate(_args).Command(app));
command.AddCommand(new GitLab.Migrate(_args).Command(app));
command.AddCommand(new Jenkins.Migrate(_args).Command(app));
Expand Down
4 changes: 3 additions & 1 deletion src/ActionsImporter/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public static class Constants
new Variable("JENKINS_INSTANCE_URL", Provider.Jenkins, "Base url of the Jenkins instance"),
new Variable("TRAVIS_CI_ACCESS_TOKEN", Provider.TravisCI, "Personal access token for Travis CI"),
new Variable("TRAVIS_CI_INSTANCE_URL", Provider.TravisCI, "Base url of the Travis CI instance", "https://travis-ci.com"),
new Variable("TRAVIS_CI_ORGANIZATION", Provider.TravisCI, "Travis CI organization name")
new Variable("TRAVIS_CI_ORGANIZATION", Provider.TravisCI, "Travis CI organization name"),
new Variable("BITBUCKET_ACCESS_TOKEN", Provider.Bitbucket, "Personal access token for Bitbucket"),

};

public static List<string> ProviderNames => UserInputVariables.Where(v => v.Provider != Provider.GitHub).Select(v => v.ProviderName).Distinct().ToList();
Expand Down
3 changes: 2 additions & 1 deletion src/ActionsImporter/Models/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public enum Provider
GitLabCI,
Jenkins,
TravisCI,
Bamboo
Bamboo,
Bitbucket
}
1 change: 1 addition & 0 deletions src/ActionsImporter/Models/Variable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public Variable(string key, Provider provider, string message, string? defaultVa
Provider.Jenkins => "Jenkins",
Provider.TravisCI => "Travis CI",
Provider.Bamboo => "Bamboo",
Provider.Bitbucket => "Bitbucket",
_ => throw new ArgumentOutOfRangeException()
};

Expand Down

0 comments on commit 4b1f8af

Please sign in to comment.