How to keep files permission during gitlab auto deployment?
up vote
0
down vote
favorite
I am trying auto deploy branch from gitlab 11.06
to a staging server.Both gitlab server and staging server are centos 7.4
Below is the .gitlab-ci.yml
:
stages:
- deploy
deploy_staging:
stage: deploy
tags:
- php
script:
/home/gitlab-runner/.local/bin/deploy.sh
deploy.sh
as below:
#!/bin/bash
deploy_path="/var/www/html"
cd $deploy_path
git pull origin master
auto deploy works fine,but owner and permission of files changed.For example:
before auto deploy:drwxr-xr-x 2 apache webadmin 77 Nov 19 8:41 phpmailer
After auto deploy:drwxrwxr-x 2 gitlab-runner gitlab-runner 77 Nov 19 10:11 phpmailer
I need auto deploy,I need to keep files permisson too.
How to keep files permission during auto deployment?Thanks in advance for any solution!
git gitlab gitlab-ci gitlab-ci-runner
add a comment |
up vote
0
down vote
favorite
I am trying auto deploy branch from gitlab 11.06
to a staging server.Both gitlab server and staging server are centos 7.4
Below is the .gitlab-ci.yml
:
stages:
- deploy
deploy_staging:
stage: deploy
tags:
- php
script:
/home/gitlab-runner/.local/bin/deploy.sh
deploy.sh
as below:
#!/bin/bash
deploy_path="/var/www/html"
cd $deploy_path
git pull origin master
auto deploy works fine,but owner and permission of files changed.For example:
before auto deploy:drwxr-xr-x 2 apache webadmin 77 Nov 19 8:41 phpmailer
After auto deploy:drwxrwxr-x 2 gitlab-runner gitlab-runner 77 Nov 19 10:11 phpmailer
I need auto deploy,I need to keep files permisson too.
How to keep files permission during auto deployment?Thanks in advance for any solution!
git gitlab gitlab-ci gitlab-ci-runner
Do you want to preserve ownership (apache/webadmin
user/group) or permissions (drwxr-xr-x
)? Or both?
– phd
Nov 20 at 15:13
@phd,both ownership and permissions.
– kittygirl
Nov 20 at 15:15
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying auto deploy branch from gitlab 11.06
to a staging server.Both gitlab server and staging server are centos 7.4
Below is the .gitlab-ci.yml
:
stages:
- deploy
deploy_staging:
stage: deploy
tags:
- php
script:
/home/gitlab-runner/.local/bin/deploy.sh
deploy.sh
as below:
#!/bin/bash
deploy_path="/var/www/html"
cd $deploy_path
git pull origin master
auto deploy works fine,but owner and permission of files changed.For example:
before auto deploy:drwxr-xr-x 2 apache webadmin 77 Nov 19 8:41 phpmailer
After auto deploy:drwxrwxr-x 2 gitlab-runner gitlab-runner 77 Nov 19 10:11 phpmailer
I need auto deploy,I need to keep files permisson too.
How to keep files permission during auto deployment?Thanks in advance for any solution!
git gitlab gitlab-ci gitlab-ci-runner
I am trying auto deploy branch from gitlab 11.06
to a staging server.Both gitlab server and staging server are centos 7.4
Below is the .gitlab-ci.yml
:
stages:
- deploy
deploy_staging:
stage: deploy
tags:
- php
script:
/home/gitlab-runner/.local/bin/deploy.sh
deploy.sh
as below:
#!/bin/bash
deploy_path="/var/www/html"
cd $deploy_path
git pull origin master
auto deploy works fine,but owner and permission of files changed.For example:
before auto deploy:drwxr-xr-x 2 apache webadmin 77 Nov 19 8:41 phpmailer
After auto deploy:drwxrwxr-x 2 gitlab-runner gitlab-runner 77 Nov 19 10:11 phpmailer
I need auto deploy,I need to keep files permisson too.
How to keep files permission during auto deployment?Thanks in advance for any solution!
git gitlab gitlab-ci gitlab-ci-runner
git gitlab gitlab-ci gitlab-ci-runner
edited Nov 20 at 0:57
asked Nov 19 at 17:01
kittygirl
275316
275316
Do you want to preserve ownership (apache/webadmin
user/group) or permissions (drwxr-xr-x
)? Or both?
– phd
Nov 20 at 15:13
@phd,both ownership and permissions.
– kittygirl
Nov 20 at 15:15
add a comment |
Do you want to preserve ownership (apache/webadmin
user/group) or permissions (drwxr-xr-x
)? Or both?
– phd
Nov 20 at 15:13
@phd,both ownership and permissions.
– kittygirl
Nov 20 at 15:15
Do you want to preserve ownership (
apache/webadmin
user/group) or permissions (drwxr-xr-x
)? Or both?– phd
Nov 20 at 15:13
Do you want to preserve ownership (
apache/webadmin
user/group) or permissions (drwxr-xr-x
)? Or both?– phd
Nov 20 at 15:13
@phd,both ownership and permissions.
– kittygirl
Nov 20 at 15:15
@phd,both ownership and permissions.
– kittygirl
Nov 20 at 15:15
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
git pull
seems to replace files (it creates a new file and move it) instead of writing to existing files. Hence there is no way for it to preserve ownership — newly created files are created with the process ownership, gitlab-runner/gitlab-runner
user/group. To fix that run git pull
under different user using e.g., sudo
. Either
sudo -u apache /home/gitlab-runner/.local/bin/deploy.sh
in the gitlab-ci.yml
or
sudo -u apache git pull origin master
in the deploy.sh
. Please don't forget that sudo
asks for password so you have to configure it to run the command(s) without password.
To retain permissions try to set umask 055
in deploy.sh
before running git pull
.
Ownership and permission are critical when I deploy to production server.Is there any solution to maintain complicated ownership and permission after auto deployment?
– kittygirl
Nov 20 at 15:42
Runsudo chown user.group file1 file2…
to change ownership if you have complex ownership requirements.
– phd
Nov 20 at 15:45
,sudo chown user.group file1 file2
ingitlab-ci.yml
or in/home/gitlab-runner/.local/bin/deploy.sh
?How can usegitlab-runner
sudoroot
?
– kittygirl
Nov 22 at 13:18
ps.can I runsetfacl
in this post aftergit pull
?
– kittygirl
Nov 22 at 14:07
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
git pull
seems to replace files (it creates a new file and move it) instead of writing to existing files. Hence there is no way for it to preserve ownership — newly created files are created with the process ownership, gitlab-runner/gitlab-runner
user/group. To fix that run git pull
under different user using e.g., sudo
. Either
sudo -u apache /home/gitlab-runner/.local/bin/deploy.sh
in the gitlab-ci.yml
or
sudo -u apache git pull origin master
in the deploy.sh
. Please don't forget that sudo
asks for password so you have to configure it to run the command(s) without password.
To retain permissions try to set umask 055
in deploy.sh
before running git pull
.
Ownership and permission are critical when I deploy to production server.Is there any solution to maintain complicated ownership and permission after auto deployment?
– kittygirl
Nov 20 at 15:42
Runsudo chown user.group file1 file2…
to change ownership if you have complex ownership requirements.
– phd
Nov 20 at 15:45
,sudo chown user.group file1 file2
ingitlab-ci.yml
or in/home/gitlab-runner/.local/bin/deploy.sh
?How can usegitlab-runner
sudoroot
?
– kittygirl
Nov 22 at 13:18
ps.can I runsetfacl
in this post aftergit pull
?
– kittygirl
Nov 22 at 14:07
add a comment |
up vote
0
down vote
git pull
seems to replace files (it creates a new file and move it) instead of writing to existing files. Hence there is no way for it to preserve ownership — newly created files are created with the process ownership, gitlab-runner/gitlab-runner
user/group. To fix that run git pull
under different user using e.g., sudo
. Either
sudo -u apache /home/gitlab-runner/.local/bin/deploy.sh
in the gitlab-ci.yml
or
sudo -u apache git pull origin master
in the deploy.sh
. Please don't forget that sudo
asks for password so you have to configure it to run the command(s) without password.
To retain permissions try to set umask 055
in deploy.sh
before running git pull
.
Ownership and permission are critical when I deploy to production server.Is there any solution to maintain complicated ownership and permission after auto deployment?
– kittygirl
Nov 20 at 15:42
Runsudo chown user.group file1 file2…
to change ownership if you have complex ownership requirements.
– phd
Nov 20 at 15:45
,sudo chown user.group file1 file2
ingitlab-ci.yml
or in/home/gitlab-runner/.local/bin/deploy.sh
?How can usegitlab-runner
sudoroot
?
– kittygirl
Nov 22 at 13:18
ps.can I runsetfacl
in this post aftergit pull
?
– kittygirl
Nov 22 at 14:07
add a comment |
up vote
0
down vote
up vote
0
down vote
git pull
seems to replace files (it creates a new file and move it) instead of writing to existing files. Hence there is no way for it to preserve ownership — newly created files are created with the process ownership, gitlab-runner/gitlab-runner
user/group. To fix that run git pull
under different user using e.g., sudo
. Either
sudo -u apache /home/gitlab-runner/.local/bin/deploy.sh
in the gitlab-ci.yml
or
sudo -u apache git pull origin master
in the deploy.sh
. Please don't forget that sudo
asks for password so you have to configure it to run the command(s) without password.
To retain permissions try to set umask 055
in deploy.sh
before running git pull
.
git pull
seems to replace files (it creates a new file and move it) instead of writing to existing files. Hence there is no way for it to preserve ownership — newly created files are created with the process ownership, gitlab-runner/gitlab-runner
user/group. To fix that run git pull
under different user using e.g., sudo
. Either
sudo -u apache /home/gitlab-runner/.local/bin/deploy.sh
in the gitlab-ci.yml
or
sudo -u apache git pull origin master
in the deploy.sh
. Please don't forget that sudo
asks for password so you have to configure it to run the command(s) without password.
To retain permissions try to set umask 055
in deploy.sh
before running git pull
.
answered Nov 20 at 15:26
phd
19.9k42441
19.9k42441
Ownership and permission are critical when I deploy to production server.Is there any solution to maintain complicated ownership and permission after auto deployment?
– kittygirl
Nov 20 at 15:42
Runsudo chown user.group file1 file2…
to change ownership if you have complex ownership requirements.
– phd
Nov 20 at 15:45
,sudo chown user.group file1 file2
ingitlab-ci.yml
or in/home/gitlab-runner/.local/bin/deploy.sh
?How can usegitlab-runner
sudoroot
?
– kittygirl
Nov 22 at 13:18
ps.can I runsetfacl
in this post aftergit pull
?
– kittygirl
Nov 22 at 14:07
add a comment |
Ownership and permission are critical when I deploy to production server.Is there any solution to maintain complicated ownership and permission after auto deployment?
– kittygirl
Nov 20 at 15:42
Runsudo chown user.group file1 file2…
to change ownership if you have complex ownership requirements.
– phd
Nov 20 at 15:45
,sudo chown user.group file1 file2
ingitlab-ci.yml
or in/home/gitlab-runner/.local/bin/deploy.sh
?How can usegitlab-runner
sudoroot
?
– kittygirl
Nov 22 at 13:18
ps.can I runsetfacl
in this post aftergit pull
?
– kittygirl
Nov 22 at 14:07
Ownership and permission are critical when I deploy to production server.Is there any solution to maintain complicated ownership and permission after auto deployment?
– kittygirl
Nov 20 at 15:42
Ownership and permission are critical when I deploy to production server.Is there any solution to maintain complicated ownership and permission after auto deployment?
– kittygirl
Nov 20 at 15:42
Run
sudo chown user.group file1 file2…
to change ownership if you have complex ownership requirements.– phd
Nov 20 at 15:45
Run
sudo chown user.group file1 file2…
to change ownership if you have complex ownership requirements.– phd
Nov 20 at 15:45
,
sudo chown user.group file1 file2
in gitlab-ci.yml
or in /home/gitlab-runner/.local/bin/deploy.sh
?How can use gitlab-runner
sudo root
?– kittygirl
Nov 22 at 13:18
,
sudo chown user.group file1 file2
in gitlab-ci.yml
or in /home/gitlab-runner/.local/bin/deploy.sh
?How can use gitlab-runner
sudo root
?– kittygirl
Nov 22 at 13:18
ps.can I run
setfacl
in this post after git pull
?– kittygirl
Nov 22 at 14:07
ps.can I run
setfacl
in this post after git pull
?– kittygirl
Nov 22 at 14:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379446%2fhow-to-keep-files-permission-during-gitlab-auto-deployment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you want to preserve ownership (
apache/webadmin
user/group) or permissions (drwxr-xr-x
)? Or both?– phd
Nov 20 at 15:13
@phd,both ownership and permissions.
– kittygirl
Nov 20 at 15:15