import Global from '../../_global.mdx';

# spfx project azuredevops pipeline add

Adds a Azure DevOps Pipeline for a SharePoint Framework project

## Usage

```sh
m365 spfx project azuredevops pipeline add [options]
```

## Options

```md definition-list
`-n, --name [name]`
: Name of the pipeline run that will be created. If none is specified a default name generated by Azure DevOps will be used

`-b, --branchName [branchName]`
: Specify the branch name which should trigger the workflow on push. If none is specified a default will be used which is 'main'

`-l, --loginMethod [loginMethod]`
: Specify the login method used for the login action. Possible options are: `user`, `application`. Default `application`

`-s, --scope [scope]`
: Scope of the app catalog: `tenant`, `sitecollection`. Default is `tenant`

`-u, --siteUrl [siteUrl]`
: The URL of the site collection where the solution package will be added. Required if scope is set to `sitecollection`

`--skipFeatureDeployment`
: When specified the app will be added to all sites. When deployed to the site app catalog it will be added to all sub-sites of that site.
```

<Global />

## Remarks

The `spfx project azuredevops pipeline add` will create a workflow .yml file in the `.azuredevops/pipelines` directory in your project. If such directory does not exist the command will automatically create it.

The command will not create the Azure DevOps pipeline. You will need to manually create it in Azure DevOps. The command will only create the workflow file which you can then push to your repo and create a new yaml pipline based on it.

For the `application` login method the command does not register an Entra application nor does it create the required certificate. In order to proceed, obtain (create) a self-signed certificate and register a new Entra application with certificate authentication. After that you will need to fill the following variables, or what is more preferable, create a dedicated variable group to store those properties:

- `CertificateBase64Encoded` - base 64 encoded certificate. Use either `CertificateBase64Encoded` or `CertificateSecureFileId` but not both
- `CertificateSecureFileId` - id of a certificate file in the secure files section of the DevOps library. `.pfx` file. Use either `CertificateBase64Encoded` or `CertificateSecureFileId` but not both
- `CertificatePassword` - certificate password. This applies only if the certificate is encoded which is the recommended approach
- `EntraAppId` - client id of the registered Entra application

This use case is perfect in a production context as it does not create any dependencies on an account

For the `user` login method you will need to fill the following variables, or what is more preferable, create a dedicated variable group to store those properties:

- `UserName` - user email
- `Password` - password

This method is perfect to test your workflow, in a dev context, for personal usage. It will not work for accounts with MFA.

:::info

Run this command in the SPFx solution folder.

:::
    
## Examples

Adds an Azure DevOps Pipeline for a SharePoint Framework project triggered on push to main

```sh
m365 spfx project azuredevops pipeline add
```

Adds an Azure DevOps Pipeline for a SharePoint Framework project with `user` login method triggered on push to main

```sh
m365 spfx project azuredevops pipeline add --loginMethod "user"
```

Adds an Azure DevOps Pipeline for a SharePoint Framework project with deployment to a site collection app catalog

```sh
m365 spfx project azuredevops pipeline add --scope "sitecollection" --siteUrl "https://some.sharepoint.com/sites/someSite"
```

## Response

The command won't return a response on success.
