0

I'm not sure, if i understood the azure-pipelines the right way. I would like:

  1. Trigger pipeline, when something is pushed into master branch
  2. Compile my assets from a laravel project in production mode npm run production
  3. Push back the compiled assets from the pipeline into master branch

Is this something I can do? To set up the pipeline was easy, I selected node.js and all things succeeded. But I couldn't find the changes in my repository. I spent hours to figure out, why it's not working, hopefully someone can help me out.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

Is this something I can do?

This is possible. It seems that you've succeeded to do #1 and #2 well. But you have to add extra step to push pack the compiled assets. (For your #3)

For details about how to git push you can check this issue. You may need a CMD task at the end of your pipeline to run below script for pushing back the compiled asserts:

For github repo:

git clone https://github.com/xxx/RepoName.git

git config --global user.email xxx@outlook.com

git config --global user.name xxx

copy "somePath/yourAsserts" RepoName

cd RepoName

git add .

git commit -m "Do sth."

git push https://UserName:UserPassword@github.com/xxx/RepoName.git master

For Azure Devops Repo:

Check this similar issue from Shayki Abramczyk. The Url of azure devops repo is a bit different, related document see here.

In addition, also grant Contribute/Contribute to PR to ProjectName Build Service user in Repositories permissions since you'll push changes back to master branch in build pipeline.

Is this something I can do?

But this is not recommended... According to your workflow, something changes in master=>build pipeline run=>build pipeline push back the compiled changes=new changes in master branch=>build run...

This is not a good workflow. I'm not familiar with the asserts you mean, but you can consider publishing the asserts to Azure Devops Artifact feed. An Npm package or Universal package feed? Hope all above helps :)

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Yeah, thanks, no I got it, thank you. In the end of the pipeline creating prozess, it says something like "commit to master" and I thought, that was my step #3 and I was always confused why it's not working. I'll find another way. Currently I'm using a normal webhosting for deployment, so I want to keep it simple and it's annoying to login to the server via ssh, get to the project path, run my commands. And of course before that setup composer, npm and all things i need... If there is someone with a good advise for me, your welcome! I found jenkins, maybe thats what i need... – hypergalaktisch May 25 '20 at 15:32
  • Hmm, maybe you can consider pushing the asserts in Azure Devops feed with Universal package format. Azure Devops Service would host them in the cloud and you can easily download/push/update those asserts in pipeline~ – LoLance May 26 '20 at 01:35