How to deploy Strapi to Azure via pipelines - azure-devops

I am quite new with Strapi, it is my first time to deploy it.
I have Strapi with MongoDB (Atlas) which work on localhost.
Now I want to deploy to Azure with keeping MongoDb on Atlas.
So my jobs for now are
Authentification
npm install
PowerShell -> install strapi cli and build my strapi project
I get en error on the last step.
My questions are
"Is it possible to use pipeline on Azure to deploy Strapi?"
and
"Can somebody explain my how to do this right?".
I would appreciate any help!!!

Above error is caused by strapi installation location not being added to the PATH environment variable of the agent machine.
You will have to add strapi installation location to PATH environment variable.
Run echo "##vso[task.setvariable variable=PATH]${env:PATH};installationFolder" in the script tasks to set PATH environment variable on hosted agent machine. Check here for more information about setting variables in scripts
On hosted agents the default installation location for yarn is C:\npm\prefix\bin rather than %LOCALAPPDATA%\Yarn\bin. See this similar thread.
So the powershell script looks like this echo "##vso[task.setvariable variable=PATH]${env:PATH};C:\npm\prefix\bin". See below screenshot.
Noted:
The change of PATH environment variable on hosted agent will only take effect in the following tasks. You need to run strapi build in a separate powershell task. See below:
Run strapi build in the following powershell task

Related

How to run script on AWS through Jenkins build

I am new to Jenkins and AWS. I have a MongoDB scripts on AWS EC2 instance. The first script need to run before the jenkins build and stores the snippets of DB. Second script need to run post build to restore to that snippets. Scripts are done ready to be used. I just couldn't find a exact way to get to AWS through build and implement this in a Jenkins job. Any help would be appreciated. Thanks
You can use Jenkins stages to to the Prebuild operation, Build and then Post build operations. With the stages you can use a plugin like SSH Pipeline Steps to remotely execute commands on your EC2 instance.

Deploy a test site azure devops pipeline (LAMP)

So I've been looking at getting the pipeline build for automation E2E Acceptance testing going.
I've been able to get the pipeline running on an agent, now the default path that the code is checked out to is
/home/myusername/myagent/_work/1/s
which is $(Pipeline.Workspace), and cannot be changed to custom path like /var/www/html/ and accepts only relative path as described here.
If I try to point the apache webroot to the above dir, I get the forbidden error. I tried
running apache as the directory owner as described here
giving full 777 permission to the directory
Now, how do I get apache to interact with those files or checkout the files inside the apache webroot /var/www/htmlin the first place so no additional work is required?
OS: Ubuntu 18

Azure Self-hosted Windows agent hook

In Azure DevOps we have a Pipeline and Release created and working. In the release, we have the Azure Self-hosted Windows agent running and publishing to the off-site server without any issues.
Once the agent has completed deployment of the website, we would like to run a script on the Self-hosted server. (example POST HOOK COMMAND > C:\srvscripts\azure-post-hook.ps1)
Where can configure the agent to run a script once the website is published?
Where can configure the agent to run a script once the website is published?
If you want to run a script once the website is published on the on the Self-hosted server, you could add a powershell task after the task your deployment the website:
Since you are running the script on the Self-hosted server, we could directly specify the path C:\srvscripts\azure-post-hook.ps1 where the script is located in the scripts path option:

How to integrate JMeter with Azure DevOps Pipeline when the scripts are kept in a git repository?

I have a requirement to integrate the JMeter scripts, checked-in a Git repository, with a DevOps pipeline so that I can run the JMeter scripts using a specific VM in Azure.
Basically, I should have all my jmxs and csvs in a git repository and when I run the pipeline, having a parameter of the script name, it should run the script on a specific VM (not with a static IP) and copy the jtl in some storage.
What is the best way to achieve this?
With a DevOps pipeline so that I can run the JMeter scripts using a
specific VM in Azure. What is the best way to achieve this?
If the specific VM exists before the current pipeline, you can consider installing self-hosted agent there.
To do CI/CD using Azure pipelines, we need at least one agent. If we use microsoft-hosted agent, it will provide one fresh VM for us to run jobs. Since you need to run the script in your own specific VM, I suggest using self-hosted agent. You can follow the steps here to install one agent into your own VM. (The steps are quite easy and only cost several minutes)
After making your VM a self-hosted agent, the pipeline will call your VM to run the jobs. Now your original issue turns into how to run JMeter locally with command-line. See similar issues here: Five Ways To Launch a JMeter Test without Using the JMeter GUI and Run .jmx file through command line ....
1.So now we can use a command-line task in pipeline to run the JMeter related commands shared in the similar topics above. And these jobs are done in your specific VM.
2.I'm not sure which location you want to copy the jtl to, but you can use Azure File Copy task to copy files to Microsoft Azure storage blobs or virtual machines (VMs). Or a simple copy/xcopy command in your command line task to copy files to another location in same machine. (Specific VM)
Hope all above helps :)
I have Use following Task in Azure CD pipeline.
"Run Taurus" Task is as following.
Where "_WM WebClient TestArtifacts" is git/Azure Repo directory where .jmx file kept(in Code).

Integration of BackstopJS into a VSTS build pipeline

At the moment I am trying to integrate the npm backstopjs into my VSTS build pipeline. To do this, I have to run it on an npm live server to get a screenshot of the actual build of the app and compare it to the reference screenshot. I tried to start this live server with a PowerShell script. This script cannot find the path to the npm root path so I cannot run the tests.
My question is: Is there a way to run BackstopJS tests with VSTS?
Edit
For the better understanding, here are some screenshots of my project:
Since Hosted VS2017 agent is the build machine provided by VSTS server, you should build VSTS with the privarte agent which located in the same machine of your live-server, so that the the build project can be searched.
And more details about deploying a private agent, you can refer the document Deploy an agent on Windows.