Azure Dev Spaces Plugin
Azure Dev Spaces Plugin helps to manage Azure Dev Spaces in a Jenkins pipeline.
NOTE:
Important: this plugin is retired. Azure Dev Spaces is being retired and will stop working on October 31, 2023.
Installation
You can install/update this plugin in Jenkins Plugin Manager.
- Sign into Jenkins
- Choose Manage Jenkins > Manage Plugins > Available tab
- Filter for the
Azure Dev Spaces Plugin
- Choose Download now and install after restart
- Restart Jenkins
If you don't see the plugin in the list, check to see if it is already installed.
You can also can manually build and install the plugin. Manual builds are helpful if you want to try out the latest features before they are released.
To manually install the plugin:
-
Clone the repo and build
mvn package
-
Sign into Jenkins, then go to Manage Jenkins > Manage Plugins.
-
On the Advanced tab, under Upload Plugin section, select Choose File.
-
Select
azure-dev-spaces.hpi
intarget
folder of your repo, and then choose Upload. -
Restart Jenkins after installation is completed.
Prerequisites for use
Azure Dev Spaces plugin requires an Azure service principal to access Azure resources. To create the service principal and add a new credential to Jenkins, refer to the Create service principal section in the Deploy to Azure App Service tutorial.
Create a dev space
Freestyle job
-
Create a new freestyle job, or open an existing job.
-
On the Build tab, in the Build section, choose Add build step. Fron the list, choose Create dev spaces.
-
Select your Azure credential, resource group, and AKS cluster from the lists.
-
Set value for your parent dev space name and dev space name.
-
In the Kubeconfig list, select the kubeconfig stored in Jenkins. Select the Add button to add new kubeconfig. Select Kubernetes configuration (kubeconfig) from the Kind list.
To get the AKS credentials, use
az aks get-credentials -g <resourcegroup> - <aksclustername> -f -
. The output will look similar to this (truncated for brevity, sensitive info redacted):apiVersion: v1 clusters: - cluster: certificate-authority-data: LS0tLS1C...JRklDQVRFLS0tLS0K server: https://jdsaks-jenkinsdevspace-xxxxxxx-xxxxxxxxx.hcp.westus2.azmk8s.io:443 name: jdsAKS contexts: - context: cluster: jdsAKS user: clusterUser_jenkinsdevspace_jdsAKS name: jdsAKS current-context: jdsAKS kind: Config preferences: {} users: - name: clusterUser_jenkinsdevspace_jdsAKS user: client-certificate-data: LS0tLS1CRU...FURS0tLS0tCg== client-key-data: LS0tLS1CR...LS0tLS0K token: 9c8971bfxxxxxxxxxxxxxxxxxxxxxxxxxxx
Copy the entire output and then paste it into the Content box.
Pipeline
The pipeline command to create a dev space is:
devSpacesCreate aksName: '', azureCredentialsId: '', resourceGroupName: '', sharedSpaceName: '', spaceName: '', kubeconfigId: ''
Example:
stage('create dev space') {
devSpacesCreate
aksName: <aks cluster name>,
azureCredentialsId: <ID of service principal credential>,
kubeconfigId: <ID of kubeconfig credential>,
resourceGroupName: <aks resource group>,
sharedSpaceName: <parent dev space name>,
spaceName: <aks namespace>
}
Clean up a dev space
Freestyle job
-
In the job configuration screen, scroll down to Post-build Actions. Add a post-build action Cleanup dev spaces.
-
Select an Azure credential, resource group, and AKS cluster.
-
In Dev Space Name, enter the name of the dev space to clean uup.
-
Select or add a Kubeconfig. See step 5, above, for details.
-
Save the project and then build it.
Pipeline
The pipeline command to clean up (delete) a dev space is:
devSpacesCleanup aksName: '', azureCredentialsId: '', devSpaceName: '', resourceGroupName: '', kubeConfigID: '', helmReleaseName: ''
helmReleaseName
is optional. It is needed only if you deployed to the dev space using Helm.
Example:
stage('cleanup') {
devSpacesCleanup
aksName: <aks cluster name>,
azureCredentialsId: <ID of service principal credential>,
devSpaceName: <name of dev space to delete>,
kubeConfigId: <ID of kubeconfig credential>,
resourceGroupName: <aks resource group>,
helmReleaseName: <release name>
}
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.