How can I copy jobs from one folder to another?

Issue

I’m trying to copy jobs from one folder to another. I can’t find a way to do that.

Environment

  • CloudBees Jenkins Enterprise
  • Folders
  • Folders Plus

Resolution

To move folders you need either Folders or Folders Plus installed.

Let’s say I have two folders: my-folder and my-folder-2 and have a Jenkins job under my-folder/my-job. If would like to move this job from one location to another one, just need to click in the dropdown menu that you can see below and click on move option.

Have more questions?

13 Comments

  • 0
    Avatar
    Bleacher Report

    No Screenshot found.....

  • 0
    Avatar
    Michael New

    It would be good if this were answered.  I see other questions on the internet but the version of jenkins is different and the options available are different.

  • 0
    Avatar
    Arnaud Héritier

    Michael I fixed the screenshot. Does it helps more ? What would we improve ?

  • 0
    Avatar
    Michael New

    It helps, but the move functionality did not work in my case...

  • 0
    Avatar
    James Brown

    Hi Michael, I've just created a ticket for us to follow up with our engineers. You should be receiving an email momentarily. 

  • 0
    Avatar
    Steven Christenson

    The question was how to "copy" not "move". So unless "move" is really a copy... then this doesn't answer the question.  However. the missing bit of information is that the pulldown is "Move/Copy/Promote" and once you get the target named, you have three options "Move", "Copy" and "Promote".  I tried this using Jenkins operation center and it ... Worked though it took a long time.  Apparently it first analyzes the job to see if the plugins on the from are compatible with the "To". Then it took a very long time to transfer.  Perhaps because it also copies all the build results.
    Above is the set up to copy from one of our Jenkins to another in the Jenkins Operation Center.




  • 0
    Avatar
    Satender Ruhil

    Hi Steven Christenson,

        I am facing issues in copying a job from 1 Jenkins instance(1.64) to another Jenkins instance(2.4). The Job is copied but some of the configurations like SCM configuration, gerrit event configuration are not present. Even shell commands are missing. Is it Jenkins Version which is preventing it from reading job of older Jenkins ??

  • 0
    Avatar
    Denys Digtiar

    Hi, Satender,

    The first thing to check is that target master has all the plugins that are required for the project or simply all the same plugins that source master has.

    If you are a CloudBees customer, feel free to raise a support ticket.

  • 0
    Avatar
    Thomas kaj Bonfils

    Create a new item and select "Copy From".

     

    In the input field, you have to provide the full path, stating with a slash, e..g

    /SourceFolder/MyJob

  • 0
    Avatar
    Allan Burdajewicz

    That's right Thomas. One difference though is that the Copy From feature only copy the job configuration.

  • 0
    Avatar
    Kim Cook

    Which plugin provides the 'Move/Copy/Promote' option?  I don't have that option in my Jenkins UI anywhere that I have searched.

  • 0
    Avatar
    Rameshmari Please Update

    How will do this programmatically? groovy script

  • 0
    Avatar
    Steven Christenson

    @Kim Cook:
    At the top of this article the requirements are listed. You'll also have to have administrative privilege.

    What is really missing, IMHO, is a way to copy multiple jobs at once. We are migrating jobs from one location to another and we have a folder full of jobs to move to a DIFFERENT folder on the destination. There isn't really an efficient way to do this. You can copy the SOURCE folder as a subfolder on the DESTINATION, but you still then have to move each job from the subfolder up to the DESTINATION folder. Either way, you end up doing one copy for EACH job.

    The other way to COPY (or move) jobs from one master to another is using the cjp-copy-item cli command. It's a little tedious, but it would look something like this:

    `ssh -port 2022 MYJenkins1 cjp-copy-item FOLDER/JOB jenkins://GUID_FOR_TARGET_JENKINS/DESTINATIONFOLDER -e IGNORE_WARNINGS -v`

    Consult the help `ssh -port 2022 MYJenkins1 help cjp-copy-item` for information. The --skip-builds option will make it just copy the job, not the builds which saves a LOT of time in cases where you don't need the build history.

     

Please sign in to leave a comment.