Hello ALM fan friends! đ At least I hope youâre ALM fans⌠because I have a pretty cool upcoming couple of posts starting with this one where weâll be building Azure DevOps pipelines that support the automation of Power Platform deployments using the Power Platform Build Tools!
In this mini-series, as part of my wider current series on the Power Platform Developer Tools, weâll look at how to build pipelines which support an ALM scenario which includes pushing our solution code to a repository, publishing our artifacts and making them ready to then deploy using a release pipeline.
In this first post, weâll build the pipeline that can take the part of the solution weâve worked on in our development environment and push it to our source control repository.
Connecting to development
First we need to work on getting a connection setup to our development environment so we can take the solutions weâve built in dev and push them into our git source control repository. Iâm using Azure Repos in this example, but Power Platform also supports using GitHub which weâll look at in a future post.
If you need help creating your service connection between Azure DevOps and your Power Platform environment, check out my post from yesterday where I discussed this.
Building the first pipeline
So now, lets get to work building the first pipeline. In our DevOps project letâs head to Pipelines in the left hand navigation, then select New pipeline.
First weâll create a variable in our pipeline that weâll reference later for our solution name.
Here Iâve created a variable called âSolutionNameâ and the value Iâve given it is the solution I want to export from my development environment. Youâll need to use the internal name of the solution not the display name.
Now, lets head to the tasks tab of our pipeline and start adding some things in here. First weâll add one of the Power Platform Build Tools tasks to our agent job. We will start by adding the âPower Platform Tool Installerâ task.
We simply need to add this task. There isnât any configuration on the task itself to do.
Next, letâs add the âPower Platform Export Solutionâ task.
On this step, we need to set the authentication type to service principal. Then select the service connection we created a few days ago in this post, referenced further up in this post too! You need to follow this post linked below before you continue hereâŚ
An introduction to the Power Platform Build Tools in Azure DevOps â Low Code Lewis
Then we will set the environment Url with the following valueâŚ
$(BuildTools.EnvironmentUrl)
We will set the solution name with the variable we created in our pipeline at the start.
$(SolutionName)
And finally we will set the Solution Output File as the following.
$(Build.ArtifactStagingDirectory)\$(SolutionName).zip
Next, letâs add the âPower Platform Unpack Solutionâ to our agent job.
Now, set the Solution Input File to the same thing we set the export solution output file to:
$(Build.ArtifactStagingDirectory)\$(SolutionName).zip
Next set the âtarget folder to unpack solutionâ input with the following:
$(Build.SourcesDirectory)\$(SolutionName)
Finally, add the command line script task to the agent jobâŚ
Then in the script use the following:
echo commit all changes
git config user.email "Email"
git config user.name "Username"
git checkout main
git add --all
git commit -m "solution"
echo push code to new repo
git push --all https://PAT_From_DevOps@dev.azure.com/RepositoryURL
In the script above, replace âEmailâ with your email in double quotes, and do the same but with the username in âUsernameâ
Then finally, get a personal access token from DevOps under âUser Settingsâ
Then replace PAT_From_DevOps with this. You can also use a secret variable here. Then continue the URL with your repository URL.
For any spaces theyâll be escaped in the URL using %20. We need to escape the % further using %%. So every normal %20 should become %%20.
Testing the pipeline
Now letâs test out the pipeline and see what we get happen!
Iâm going to save and queue my pipeline and run it using my self-hosted agent.
And there we go! My pipeline has run successfullyâŚ
And you can see I have my solution pushed to my repository!
Upcoming Content
Liked this blog post? Well youâre in luck! I have more posts coming up in the next few days where weâll build a few more pipelines for pushing our solution into a staging / build environment, and then to test as  a managed solution!
Donât want to miss the cool topic coming up, as part of this wider series on the Power Platform Developer Tools? Make sure youâre subscribed to my blog, to get all the latest directly in your inbox!
Subscribe