Push from GitLab to Azure
At the moment I have an on premise GitLab Server
that has access to internet but it is not accessible from outside and I want him to be able to push changes to an Azure Webapp
.
I found this that shows a way to automate Azure pulling from GitLab, but since it's not accessible from the outside it would be impossible to setup. There is any way where the GitLab server pushes (publishes) the commits to master into an Azure webapp
?
I really appreciate any help you can provide.
Edit: Repository Mirroring seemed like a good solution but looks like it's a Gitlab EE
feature.
If Azure machine can connect to GitLab, you can setup GitLab CI runner that will get changes from GitLab and run your custom script. This way GitLab doesn't have to talk to Azure, Azure will automatically pull changes from GitLab. Any recent GitLab version bundles GitLab-CI service that you can enable in your project. More on CI-runner configuration here and GitLab-CI.
One way to do this, via a stage in your CI process, is to extract the per site credential, then you can push using git remote functionality. I was able to do this via Azure CLI 2.0
Extract username and Password site-credentials from this new app
az appservice web deployment list-site-credentials --name $CI_PROJECT_NAME --resource-group $CI_PROJECT_NAME | jq -r '.publishingUserName' >> username
az appservice web deployment list-site-credentials --name $CI_PROJECT_NAME --resource-group $CI_PROJECT_NAME | jq -r '.publishingPassword' >> password
Store username and pass as variables
user=$(cat username)
pass=$(cat password)
Staging bits - Ugly AF (should be artifacts based)
mkdir staging
mv * staging/
cd staging
git init
git add -A
git -c user.name=’Runner' -c user.email='runner@local.com' commit -m "Sample git msg"
git remote add azure "https://${user}:${pass}@$CI_PROJECT_NAME.scm.azurewebsites.net/${CI_PROJECT_NAME}-$$CI_PROJECT_NAME.git"
git remote -v
git push -f azure master
cd ..
rm -rf staging
This is not pretty, please by all means improve on this.
链接地址: http://www.djcxy.com/p/85112.html上一篇: CI将分支推送到远程部署
下一篇: 从GitLab推送到Azure