Should a plugin be used to deploy from Bitbucket to NAS via Jenkins?










0















I have a rather simple branching strategy set up:



  • Master

  • Development

  • Production

After a pull request is approved from Development, I would like to trigger Jenkins to deploy the branch content to a NAS share, overwritting if necessary. The same for Production, except the NAS location is different.



My question is, out of the following options, what would be the best way to accomplish this?



  1. Write a bash script to move the files from the Jenkins workspace to the target location.

  2. Somehow use git pull directly from the target location.

  3. Access share remotely through a service user that has read+write and execute a git pull from the target. Maybe something like \servernamesharenamerepo?

  4. None of the above.

Also, I have presented the NAS shares directly to the VM where Jenkins is running. Is this absolutely necessary or is there a better option? I should also mention that these are just scripts, configuration files, and other flat files... nothing needs to be compiled. The total size of the branch could be between 100MB to 200MB (just in case this is too large and would cause perf problems by going the "git pull" route).



I am just getting into the world of continuous delivery so please forgive my ignorance in advance.




UPDATE: I was able to get something working by using the Publish Over SSH plugin. However, now I am trying to figure out the best way to use this plugin. Is it possible to set up a pipeline with this plugin? Right now, I have a generic Freestyle project but need to be able to deploy my Development branch to my Development NAS when a pull request to Development is approved... and need to be able to deploy my Production branch to my Production NAS when a pull request to Production is approved.



Has anyone done this? If so, did you use a Pipeline, Multibranch Pipeline, or Other?




ANOTHER UPDATE: I was able to figure most of everything out. I created a multibranch pipeline with a custom Jenkinsfile similar to the following:



pipeline 
agent any
stages
stage('Build')
steps
sh 'echo "Building project"'


stage('Test')
steps
sh 'echo "We can eventually build some unit tests here."'


stage('Deliver for development')
when
branch 'development'

steps
sh 'echo "Run Publish over SSH Plugin to push to development NAS."'
sshPublisher(
failOnError: true,
publishers: [
sshPublisherDesc(
configName: 'nas_dev',
transfers: [
sshTransfer(
sourceFiles: '**/*'
)
]
)
]
)


stage('Deploy for production')
when
branch 'production'

steps
sh 'echo "Run Publish over SSH Plugin to push to production NAS."'
sshPublisher(
failOnError: true,
publishers: [
sshPublisherDesc(
configName: 'nas_prd',
transfers: [
sshTransfer(
sourceFiles: '**/*'
)
]
)
]
)






The problem I now face is around actually mirroring the workspace to the target NAS location. For example, if I delete a file from my git repo, Jenkins fires, creates a workspace, then copies to NAS via Publish over SSH, the file that was deleted is still in the target NAS location. I was hoping this would work similar to what RSYNC would do but I am not finding that to be the case.



Does anyone know how to accomplish this? Also, there is a persistent directory in the target NAS location that I cannot delete.










share|improve this question




























    0















    I have a rather simple branching strategy set up:



    • Master

    • Development

    • Production

    After a pull request is approved from Development, I would like to trigger Jenkins to deploy the branch content to a NAS share, overwritting if necessary. The same for Production, except the NAS location is different.



    My question is, out of the following options, what would be the best way to accomplish this?



    1. Write a bash script to move the files from the Jenkins workspace to the target location.

    2. Somehow use git pull directly from the target location.

    3. Access share remotely through a service user that has read+write and execute a git pull from the target. Maybe something like \servernamesharenamerepo?

    4. None of the above.

    Also, I have presented the NAS shares directly to the VM where Jenkins is running. Is this absolutely necessary or is there a better option? I should also mention that these are just scripts, configuration files, and other flat files... nothing needs to be compiled. The total size of the branch could be between 100MB to 200MB (just in case this is too large and would cause perf problems by going the "git pull" route).



    I am just getting into the world of continuous delivery so please forgive my ignorance in advance.




    UPDATE: I was able to get something working by using the Publish Over SSH plugin. However, now I am trying to figure out the best way to use this plugin. Is it possible to set up a pipeline with this plugin? Right now, I have a generic Freestyle project but need to be able to deploy my Development branch to my Development NAS when a pull request to Development is approved... and need to be able to deploy my Production branch to my Production NAS when a pull request to Production is approved.



    Has anyone done this? If so, did you use a Pipeline, Multibranch Pipeline, or Other?




    ANOTHER UPDATE: I was able to figure most of everything out. I created a multibranch pipeline with a custom Jenkinsfile similar to the following:



    pipeline 
    agent any
    stages
    stage('Build')
    steps
    sh 'echo "Building project"'


    stage('Test')
    steps
    sh 'echo "We can eventually build some unit tests here."'


    stage('Deliver for development')
    when
    branch 'development'

    steps
    sh 'echo "Run Publish over SSH Plugin to push to development NAS."'
    sshPublisher(
    failOnError: true,
    publishers: [
    sshPublisherDesc(
    configName: 'nas_dev',
    transfers: [
    sshTransfer(
    sourceFiles: '**/*'
    )
    ]
    )
    ]
    )


    stage('Deploy for production')
    when
    branch 'production'

    steps
    sh 'echo "Run Publish over SSH Plugin to push to production NAS."'
    sshPublisher(
    failOnError: true,
    publishers: [
    sshPublisherDesc(
    configName: 'nas_prd',
    transfers: [
    sshTransfer(
    sourceFiles: '**/*'
    )
    ]
    )
    ]
    )






    The problem I now face is around actually mirroring the workspace to the target NAS location. For example, if I delete a file from my git repo, Jenkins fires, creates a workspace, then copies to NAS via Publish over SSH, the file that was deleted is still in the target NAS location. I was hoping this would work similar to what RSYNC would do but I am not finding that to be the case.



    Does anyone know how to accomplish this? Also, there is a persistent directory in the target NAS location that I cannot delete.










    share|improve this question


























      0












      0








      0








      I have a rather simple branching strategy set up:



      • Master

      • Development

      • Production

      After a pull request is approved from Development, I would like to trigger Jenkins to deploy the branch content to a NAS share, overwritting if necessary. The same for Production, except the NAS location is different.



      My question is, out of the following options, what would be the best way to accomplish this?



      1. Write a bash script to move the files from the Jenkins workspace to the target location.

      2. Somehow use git pull directly from the target location.

      3. Access share remotely through a service user that has read+write and execute a git pull from the target. Maybe something like \servernamesharenamerepo?

      4. None of the above.

      Also, I have presented the NAS shares directly to the VM where Jenkins is running. Is this absolutely necessary or is there a better option? I should also mention that these are just scripts, configuration files, and other flat files... nothing needs to be compiled. The total size of the branch could be between 100MB to 200MB (just in case this is too large and would cause perf problems by going the "git pull" route).



      I am just getting into the world of continuous delivery so please forgive my ignorance in advance.




      UPDATE: I was able to get something working by using the Publish Over SSH plugin. However, now I am trying to figure out the best way to use this plugin. Is it possible to set up a pipeline with this plugin? Right now, I have a generic Freestyle project but need to be able to deploy my Development branch to my Development NAS when a pull request to Development is approved... and need to be able to deploy my Production branch to my Production NAS when a pull request to Production is approved.



      Has anyone done this? If so, did you use a Pipeline, Multibranch Pipeline, or Other?




      ANOTHER UPDATE: I was able to figure most of everything out. I created a multibranch pipeline with a custom Jenkinsfile similar to the following:



      pipeline 
      agent any
      stages
      stage('Build')
      steps
      sh 'echo "Building project"'


      stage('Test')
      steps
      sh 'echo "We can eventually build some unit tests here."'


      stage('Deliver for development')
      when
      branch 'development'

      steps
      sh 'echo "Run Publish over SSH Plugin to push to development NAS."'
      sshPublisher(
      failOnError: true,
      publishers: [
      sshPublisherDesc(
      configName: 'nas_dev',
      transfers: [
      sshTransfer(
      sourceFiles: '**/*'
      )
      ]
      )
      ]
      )


      stage('Deploy for production')
      when
      branch 'production'

      steps
      sh 'echo "Run Publish over SSH Plugin to push to production NAS."'
      sshPublisher(
      failOnError: true,
      publishers: [
      sshPublisherDesc(
      configName: 'nas_prd',
      transfers: [
      sshTransfer(
      sourceFiles: '**/*'
      )
      ]
      )
      ]
      )






      The problem I now face is around actually mirroring the workspace to the target NAS location. For example, if I delete a file from my git repo, Jenkins fires, creates a workspace, then copies to NAS via Publish over SSH, the file that was deleted is still in the target NAS location. I was hoping this would work similar to what RSYNC would do but I am not finding that to be the case.



      Does anyone know how to accomplish this? Also, there is a persistent directory in the target NAS location that I cannot delete.










      share|improve this question
















      I have a rather simple branching strategy set up:



      • Master

      • Development

      • Production

      After a pull request is approved from Development, I would like to trigger Jenkins to deploy the branch content to a NAS share, overwritting if necessary. The same for Production, except the NAS location is different.



      My question is, out of the following options, what would be the best way to accomplish this?



      1. Write a bash script to move the files from the Jenkins workspace to the target location.

      2. Somehow use git pull directly from the target location.

      3. Access share remotely through a service user that has read+write and execute a git pull from the target. Maybe something like \servernamesharenamerepo?

      4. None of the above.

      Also, I have presented the NAS shares directly to the VM where Jenkins is running. Is this absolutely necessary or is there a better option? I should also mention that these are just scripts, configuration files, and other flat files... nothing needs to be compiled. The total size of the branch could be between 100MB to 200MB (just in case this is too large and would cause perf problems by going the "git pull" route).



      I am just getting into the world of continuous delivery so please forgive my ignorance in advance.




      UPDATE: I was able to get something working by using the Publish Over SSH plugin. However, now I am trying to figure out the best way to use this plugin. Is it possible to set up a pipeline with this plugin? Right now, I have a generic Freestyle project but need to be able to deploy my Development branch to my Development NAS when a pull request to Development is approved... and need to be able to deploy my Production branch to my Production NAS when a pull request to Production is approved.



      Has anyone done this? If so, did you use a Pipeline, Multibranch Pipeline, or Other?




      ANOTHER UPDATE: I was able to figure most of everything out. I created a multibranch pipeline with a custom Jenkinsfile similar to the following:



      pipeline 
      agent any
      stages
      stage('Build')
      steps
      sh 'echo "Building project"'


      stage('Test')
      steps
      sh 'echo "We can eventually build some unit tests here."'


      stage('Deliver for development')
      when
      branch 'development'

      steps
      sh 'echo "Run Publish over SSH Plugin to push to development NAS."'
      sshPublisher(
      failOnError: true,
      publishers: [
      sshPublisherDesc(
      configName: 'nas_dev',
      transfers: [
      sshTransfer(
      sourceFiles: '**/*'
      )
      ]
      )
      ]
      )


      stage('Deploy for production')
      when
      branch 'production'

      steps
      sh 'echo "Run Publish over SSH Plugin to push to production NAS."'
      sshPublisher(
      failOnError: true,
      publishers: [
      sshPublisherDesc(
      configName: 'nas_prd',
      transfers: [
      sshTransfer(
      sourceFiles: '**/*'
      )
      ]
      )
      ]
      )






      The problem I now face is around actually mirroring the workspace to the target NAS location. For example, if I delete a file from my git repo, Jenkins fires, creates a workspace, then copies to NAS via Publish over SSH, the file that was deleted is still in the target NAS location. I was hoping this would work similar to what RSYNC would do but I am not finding that to be the case.



      Does anyone know how to accomplish this? Also, there is a persistent directory in the target NAS location that I cannot delete.







      jenkins jenkins-plugins jenkins-pipeline






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 21:50







      sconicelli

















      asked Nov 13 '18 at 19:21









      sconicellisconicelli

      426




      426






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288114%2fshould-a-plugin-be-used-to-deploy-from-bitbucket-to-nas-via-jenkins%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53288114%2fshould-a-plugin-be-used-to-deploy-from-bitbucket-to-nas-via-jenkins%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          政党

          天津地下鉄3号線