AWS CodePipeline

Tier: Free, Premium, Ultimate Offering: GitLab.com
History

You can use your GitLab project to build, test, and deploy code changes using AWS CodePipeline. To do so, you use:

  • AWS CodeStar Connections to connect your GitLab.com account to AWS.
  • That connection to automatically start a pipeline based on changes to your code.

Create a connection from AWS CodePipeline to GitLab

Prerequisites:

  • You must have the Owner role on the GitLab project that you are connecting with AWS CodePipeline.
  • You must have the appropriate permissions to create a connection in AWS.
  • You must use a supported AWS region. Unsupported regions (also listed in the AWS documentation) are:
    • Asia Pacific (Hong Kong).
    • Africa (Cape Town).
    • Middle East (Bahrain).
    • Europe (Zurich).
    • AWS GovCloud (US-West and US-East).

To create a connection to a project on GitLab.com, you can use either the AWS Management Console, or the AWS Command Line Interface (AWS CLI).

Use the AWS Management Console

To connect a new or existing pipeline in AWS CodePipeline with GitLab.com, first authorize the AWS connection to use your GitLab account.

  1. Sign in to the AWS Management Console, and open the AWS Developer Tools console.
  2. Select Settings > Connections > Create connection.
  3. In Select a provider, select GitLab.
  4. In Connection name, enter the name for the connection that you want to create and select Connect to GitLab.
  5. In the GitLab sign-in page, enter your credentials and select Sign in.
  6. An authorization page displays with a message requesting authorization for the connection to access your GitLab account. Select Authorize.
  7. The browser returns to the connections console page. In the Create GitLab connection section, the new connection is shown in Connection name.
  8. Select Connect to GitLab. After the connection is created successfully, a success banner displays. The connection details are shown on the Connection settings page.

Now you’ve connected AWS CodeSuite to GitLab.com, you can create or edit a pipeline in AWS CodePipeline that leverages your GitLab projects.

  1. Sign in to the AWS CodePipeline console.
  2. Create or edit a pipeline:
    • If you are creating a pipeline:
      • Complete the fields in the first screen and select Next.
      • On the Source page, in the Source Provider section, select GitLab.
    • If you are editing an existing pipeline:
      • Select Edit > Edit stage to add or edit your source action.
      • On the Edit action page, in the Action name section, enter the name for your action.
      • In Action provider, select GitLab.
  3. In Connection, select the connection you created earlier.
  4. In Repository name, to choose the name of your GitLab project, specify the full project path with the namespace and all subgroups. For example, for a group-level project, enter the project name in the following format: group-name/subgroup-name/project-name. The project path with the namespace is in the URL in GitLab. Do not copy URLs from the Web IDE or raw views as they contain other special URL segments. You can also pick an option from the dialog, or type a new path manually. For more information about the:
    • Path and namespace, see the path_with_namespace field in the projects API.
    • Namespace in GitLab, see namespaces.
  5. In Branch name, select the branch where you want your pipeline to detect source changes. If the branch name does not populate automatically, this might be because of one of the following:
    • You do not have the Owner role for the project.
    • The project name is not valid.
    • The connection used does not have access to the project.
  6. In Output artifact format, select the format for your artifacts. To store:
  7. Save the source action and continue.

Use the AWS CLI

To use the AWS CLI to create a connection:

  • Use the create-connection command.
  • Go to the AWS Console to authenticate with your GitLab.com account.
  • Connect your GitLab project to AWS CodePipeline.

To use the create-connection command:

  1. Open a terminal (Linux, macOS, or Unix) or command prompt (Windows). Use the AWS CLI to run the create-connection command, specifying the --provider-type and --connection-name for your connection. In this example, the third-party provider name is GitLab and the specified connection name is MyConnection.

    aws codestar-connections create-connection --provider-type GitLab --connection-name MyConnection
    

    If successful, this command returns the connection’s Amazon Resource Name (ARN) information. For example:

    {
    "ConnectionArn": "arn:aws:codestar-connections:us-west-2:account_id:connection/aEXAMPLE-8aad-4d5d-8878-dfcab0bc441f"
    }
    
  2. The new connection is created with a PENDING status by default. Use the console to change the connection’s status to AVAILABLE.

  3. Use the AWS Console to complete the connection. Make sure you select your pending GitLab connection. Do not select Create connection.