Angular CLI & Jenkins continous integration permissions

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












I'm using jenkins for a continuous integration with angular cli, here are my steps :



  • Push to github

  • Jenkins pull the code from my github repository, do npm install and ng build

Everything is fine until here.



My problem is when I try to copy all the files build in /var/lib/jenkins/workspace/mywebsite/dist to /var/www/html/mywebsite



This directory is managed by Nginx.



I've got this error :
cp: cannot create regular file '/var/www/html/mywebsite/./inline.bundle.js': Permission denied



Can someone help me ?



Thanks










share|improve this question























  • Did you use sudo when you copied data over? Or, have you considered just symlinking the directory rather than copying data?
    – Thomas Ward♦
    Mar 7 at 15:57










  • This also isn't an NGINX question but a system permissions question. It only tangentially has to do with nginx in its current state.
    – Thomas Ward♦
    Mar 7 at 16:07










  • I think it's not permitted to do sudo in jenkins Execute Shell section. I'll try with the symlink. Thanks
    – andy200486
    Mar 7 at 16:37










  • When I try sudo, I have this error : sudo: no tty present and no askpass program specified
    – andy200486
    Mar 7 at 16:38










  • I had assumed you have access to the system directly or via SSH, rather than using Jenkins' shell as a go-between. You can't create the symlink either without superuser privileges, so you may be out of luck with what you're trying to do, unless you have direct system access over SSH or such to make system-level revisions
    – Thomas Ward♦
    Mar 7 at 16:39















up vote
1
down vote

favorite












I'm using jenkins for a continuous integration with angular cli, here are my steps :



  • Push to github

  • Jenkins pull the code from my github repository, do npm install and ng build

Everything is fine until here.



My problem is when I try to copy all the files build in /var/lib/jenkins/workspace/mywebsite/dist to /var/www/html/mywebsite



This directory is managed by Nginx.



I've got this error :
cp: cannot create regular file '/var/www/html/mywebsite/./inline.bundle.js': Permission denied



Can someone help me ?



Thanks










share|improve this question























  • Did you use sudo when you copied data over? Or, have you considered just symlinking the directory rather than copying data?
    – Thomas Ward♦
    Mar 7 at 15:57










  • This also isn't an NGINX question but a system permissions question. It only tangentially has to do with nginx in its current state.
    – Thomas Ward♦
    Mar 7 at 16:07










  • I think it's not permitted to do sudo in jenkins Execute Shell section. I'll try with the symlink. Thanks
    – andy200486
    Mar 7 at 16:37










  • When I try sudo, I have this error : sudo: no tty present and no askpass program specified
    – andy200486
    Mar 7 at 16:38










  • I had assumed you have access to the system directly or via SSH, rather than using Jenkins' shell as a go-between. You can't create the symlink either without superuser privileges, so you may be out of luck with what you're trying to do, unless you have direct system access over SSH or such to make system-level revisions
    – Thomas Ward♦
    Mar 7 at 16:39













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm using jenkins for a continuous integration with angular cli, here are my steps :



  • Push to github

  • Jenkins pull the code from my github repository, do npm install and ng build

Everything is fine until here.



My problem is when I try to copy all the files build in /var/lib/jenkins/workspace/mywebsite/dist to /var/www/html/mywebsite



This directory is managed by Nginx.



I've got this error :
cp: cannot create regular file '/var/www/html/mywebsite/./inline.bundle.js': Permission denied



Can someone help me ?



Thanks










share|improve this question















I'm using jenkins for a continuous integration with angular cli, here are my steps :



  • Push to github

  • Jenkins pull the code from my github repository, do npm install and ng build

Everything is fine until here.



My problem is when I try to copy all the files build in /var/lib/jenkins/workspace/mywebsite/dist to /var/www/html/mywebsite



This directory is managed by Nginx.



I've got this error :
cp: cannot create regular file '/var/www/html/mywebsite/./inline.bundle.js': Permission denied



Can someone help me ?



Thanks







permissions jenkins






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 16:07









Thomas Ward♦

41.5k23112166




41.5k23112166










asked Mar 7 at 15:50









andy200486

82




82











  • Did you use sudo when you copied data over? Or, have you considered just symlinking the directory rather than copying data?
    – Thomas Ward♦
    Mar 7 at 15:57










  • This also isn't an NGINX question but a system permissions question. It only tangentially has to do with nginx in its current state.
    – Thomas Ward♦
    Mar 7 at 16:07










  • I think it's not permitted to do sudo in jenkins Execute Shell section. I'll try with the symlink. Thanks
    – andy200486
    Mar 7 at 16:37










  • When I try sudo, I have this error : sudo: no tty present and no askpass program specified
    – andy200486
    Mar 7 at 16:38










  • I had assumed you have access to the system directly or via SSH, rather than using Jenkins' shell as a go-between. You can't create the symlink either without superuser privileges, so you may be out of luck with what you're trying to do, unless you have direct system access over SSH or such to make system-level revisions
    – Thomas Ward♦
    Mar 7 at 16:39

















  • Did you use sudo when you copied data over? Or, have you considered just symlinking the directory rather than copying data?
    – Thomas Ward♦
    Mar 7 at 15:57










  • This also isn't an NGINX question but a system permissions question. It only tangentially has to do with nginx in its current state.
    – Thomas Ward♦
    Mar 7 at 16:07










  • I think it's not permitted to do sudo in jenkins Execute Shell section. I'll try with the symlink. Thanks
    – andy200486
    Mar 7 at 16:37










  • When I try sudo, I have this error : sudo: no tty present and no askpass program specified
    – andy200486
    Mar 7 at 16:38










  • I had assumed you have access to the system directly or via SSH, rather than using Jenkins' shell as a go-between. You can't create the symlink either without superuser privileges, so you may be out of luck with what you're trying to do, unless you have direct system access over SSH or such to make system-level revisions
    – Thomas Ward♦
    Mar 7 at 16:39
















Did you use sudo when you copied data over? Or, have you considered just symlinking the directory rather than copying data?
– Thomas Ward♦
Mar 7 at 15:57




Did you use sudo when you copied data over? Or, have you considered just symlinking the directory rather than copying data?
– Thomas Ward♦
Mar 7 at 15:57












This also isn't an NGINX question but a system permissions question. It only tangentially has to do with nginx in its current state.
– Thomas Ward♦
Mar 7 at 16:07




This also isn't an NGINX question but a system permissions question. It only tangentially has to do with nginx in its current state.
– Thomas Ward♦
Mar 7 at 16:07












I think it's not permitted to do sudo in jenkins Execute Shell section. I'll try with the symlink. Thanks
– andy200486
Mar 7 at 16:37




I think it's not permitted to do sudo in jenkins Execute Shell section. I'll try with the symlink. Thanks
– andy200486
Mar 7 at 16:37












When I try sudo, I have this error : sudo: no tty present and no askpass program specified
– andy200486
Mar 7 at 16:38




When I try sudo, I have this error : sudo: no tty present and no askpass program specified
– andy200486
Mar 7 at 16:38












I had assumed you have access to the system directly or via SSH, rather than using Jenkins' shell as a go-between. You can't create the symlink either without superuser privileges, so you may be out of luck with what you're trying to do, unless you have direct system access over SSH or such to make system-level revisions
– Thomas Ward♦
Mar 7 at 16:39





I had assumed you have access to the system directly or via SSH, rather than using Jenkins' shell as a go-between. You can't create the symlink either without superuser privileges, so you may be out of luck with what you're trying to do, unless you have direct system access over SSH or such to make system-level revisions
– Thomas Ward♦
Mar 7 at 16:39











1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Unfortunately, you can't just easily copy the data over. Rather, why not let NGINX go fetch the data via a symlink?



Create a symlink of the build destination directory in /var/www instead:



sudo mv /var/www/html /var/www/html.old
sudo ln -s /var/lib/jenkins/workspace/mywebsite/dist /var/www/html


This should, assuming that NGINX can also read the data in the /var/lib/jenkins/workspace/mywebsite/dist folder, bypass the need to let Jenkins directly copy things into a folder outside its control.



Note that I strongly suggest you use /var/www/domain.tld, replacing domain.tld with your actual site, and then use that for the document root in the nginx site configuration instead of /var/www/html. There is an NGINX Configuration Pitfalls entry about the potential issues of using the default document root which is relevant here. It specifically states:




Using the Default Document Root



NGINX packages that exist in Ubuntu, Debian, or other operating
systems, as an easy-to-install package will often provide a ‘default’
configuration file as an example of configuration methods, and will
often include a document root to hold a basic HTML file.



Most of these packaging systems do not check to see if files are
modified or exist within the default document root, which can result
in code loss when the packages are upgraded. Experienced system
administrators know that there is no expectation of the data inside
the default document root to remain untouched during upgrades.



You should not use the default document root for any site-critical
files. There is no expectation that the default document root will be
left untouched by the system and there is an extremely high
possibility that your site-critical data may be lost upon updates and
upgrades to the NGINX packages for your operating system.







share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1012767%2fangular-cli-jenkins-continous-integration-permissions%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    Unfortunately, you can't just easily copy the data over. Rather, why not let NGINX go fetch the data via a symlink?



    Create a symlink of the build destination directory in /var/www instead:



    sudo mv /var/www/html /var/www/html.old
    sudo ln -s /var/lib/jenkins/workspace/mywebsite/dist /var/www/html


    This should, assuming that NGINX can also read the data in the /var/lib/jenkins/workspace/mywebsite/dist folder, bypass the need to let Jenkins directly copy things into a folder outside its control.



    Note that I strongly suggest you use /var/www/domain.tld, replacing domain.tld with your actual site, and then use that for the document root in the nginx site configuration instead of /var/www/html. There is an NGINX Configuration Pitfalls entry about the potential issues of using the default document root which is relevant here. It specifically states:




    Using the Default Document Root



    NGINX packages that exist in Ubuntu, Debian, or other operating
    systems, as an easy-to-install package will often provide a ‘default’
    configuration file as an example of configuration methods, and will
    often include a document root to hold a basic HTML file.



    Most of these packaging systems do not check to see if files are
    modified or exist within the default document root, which can result
    in code loss when the packages are upgraded. Experienced system
    administrators know that there is no expectation of the data inside
    the default document root to remain untouched during upgrades.



    You should not use the default document root for any site-critical
    files. There is no expectation that the default document root will be
    left untouched by the system and there is an extremely high
    possibility that your site-critical data may be lost upon updates and
    upgrades to the NGINX packages for your operating system.







    share|improve this answer
























      up vote
      0
      down vote



      accepted










      Unfortunately, you can't just easily copy the data over. Rather, why not let NGINX go fetch the data via a symlink?



      Create a symlink of the build destination directory in /var/www instead:



      sudo mv /var/www/html /var/www/html.old
      sudo ln -s /var/lib/jenkins/workspace/mywebsite/dist /var/www/html


      This should, assuming that NGINX can also read the data in the /var/lib/jenkins/workspace/mywebsite/dist folder, bypass the need to let Jenkins directly copy things into a folder outside its control.



      Note that I strongly suggest you use /var/www/domain.tld, replacing domain.tld with your actual site, and then use that for the document root in the nginx site configuration instead of /var/www/html. There is an NGINX Configuration Pitfalls entry about the potential issues of using the default document root which is relevant here. It specifically states:




      Using the Default Document Root



      NGINX packages that exist in Ubuntu, Debian, or other operating
      systems, as an easy-to-install package will often provide a ‘default’
      configuration file as an example of configuration methods, and will
      often include a document root to hold a basic HTML file.



      Most of these packaging systems do not check to see if files are
      modified or exist within the default document root, which can result
      in code loss when the packages are upgraded. Experienced system
      administrators know that there is no expectation of the data inside
      the default document root to remain untouched during upgrades.



      You should not use the default document root for any site-critical
      files. There is no expectation that the default document root will be
      left untouched by the system and there is an extremely high
      possibility that your site-critical data may be lost upon updates and
      upgrades to the NGINX packages for your operating system.







      share|improve this answer






















        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        Unfortunately, you can't just easily copy the data over. Rather, why not let NGINX go fetch the data via a symlink?



        Create a symlink of the build destination directory in /var/www instead:



        sudo mv /var/www/html /var/www/html.old
        sudo ln -s /var/lib/jenkins/workspace/mywebsite/dist /var/www/html


        This should, assuming that NGINX can also read the data in the /var/lib/jenkins/workspace/mywebsite/dist folder, bypass the need to let Jenkins directly copy things into a folder outside its control.



        Note that I strongly suggest you use /var/www/domain.tld, replacing domain.tld with your actual site, and then use that for the document root in the nginx site configuration instead of /var/www/html. There is an NGINX Configuration Pitfalls entry about the potential issues of using the default document root which is relevant here. It specifically states:




        Using the Default Document Root



        NGINX packages that exist in Ubuntu, Debian, or other operating
        systems, as an easy-to-install package will often provide a ‘default’
        configuration file as an example of configuration methods, and will
        often include a document root to hold a basic HTML file.



        Most of these packaging systems do not check to see if files are
        modified or exist within the default document root, which can result
        in code loss when the packages are upgraded. Experienced system
        administrators know that there is no expectation of the data inside
        the default document root to remain untouched during upgrades.



        You should not use the default document root for any site-critical
        files. There is no expectation that the default document root will be
        left untouched by the system and there is an extremely high
        possibility that your site-critical data may be lost upon updates and
        upgrades to the NGINX packages for your operating system.







        share|improve this answer












        Unfortunately, you can't just easily copy the data over. Rather, why not let NGINX go fetch the data via a symlink?



        Create a symlink of the build destination directory in /var/www instead:



        sudo mv /var/www/html /var/www/html.old
        sudo ln -s /var/lib/jenkins/workspace/mywebsite/dist /var/www/html


        This should, assuming that NGINX can also read the data in the /var/lib/jenkins/workspace/mywebsite/dist folder, bypass the need to let Jenkins directly copy things into a folder outside its control.



        Note that I strongly suggest you use /var/www/domain.tld, replacing domain.tld with your actual site, and then use that for the document root in the nginx site configuration instead of /var/www/html. There is an NGINX Configuration Pitfalls entry about the potential issues of using the default document root which is relevant here. It specifically states:




        Using the Default Document Root



        NGINX packages that exist in Ubuntu, Debian, or other operating
        systems, as an easy-to-install package will often provide a ‘default’
        configuration file as an example of configuration methods, and will
        often include a document root to hold a basic HTML file.



        Most of these packaging systems do not check to see if files are
        modified or exist within the default document root, which can result
        in code loss when the packages are upgraded. Experienced system
        administrators know that there is no expectation of the data inside
        the default document root to remain untouched during upgrades.



        You should not use the default document root for any site-critical
        files. There is no expectation that the default document root will be
        left untouched by the system and there is an extremely high
        possibility that your site-critical data may be lost upon updates and
        upgrades to the NGINX packages for your operating system.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 21:37









        Thomas Ward♦

        41.5k23112166




        41.5k23112166



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1012767%2fangular-cli-jenkins-continous-integration-permissions%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491