Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54418

Ability to select images based on OS_FAMILY and select lastest version

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins with GCE plugin

      I have a jenkins job that uses packer to generate my GCE images on demand, so that we can maintain our build and dev environments in version control. When building this way, we can set an "image_family" parameter to a custom string, and name the image with version string.

       

      It would be great if, in the configuration there was an option to select the image via 'OS Family', and always use the latest version. This way, we don't have to constantly adjust the image used, and it can be picked up dynamically. 

       

      EDIT
      After a bit of research I found that what you would want to use is  compute.Images.GetFromFamily. I do not know java very well, and I wouldn't know where to begin or I would do this myself. But I think if you just copy the current "image name" and add "os family" parameter to the form, and make it so one of them is required, or use radio boxes to select between them, then take the input from os family, save it in the settings db.

      Then when an instance is created, check if this setting is in the DB or not, and if it is, then call the compute.Images.GetFromFamily on it, and pass it to the create instance function. it could work automatically, as the documentation says it will already return the latest.

      Here is the documentation:
      https://developers.google.com/resources/api-libraries/documentation/compute/v1/java/latest/com/google/api/services/compute/Compute.Images.GetFromFamily.html

      Thanks! 

          [JENKINS-54418] Ability to select images based on OS_FAMILY and select lastest version

          Karol Lassak added a comment -

          This functionality can now be achieved via templates which was added in 1.8.0.

          zombiemoose I think that this issue can be closed now..

          Karol Lassak added a comment - This functionality can now be achieved via templates which was added in 1.8.0. zombiemoose  I think that this issue can be closed now..

          Rachel Yen added a comment -

          Hmm, it sounds like new images are being generated whenever you run a new job? ingwar I'm not sure we solve that with templates since we would still be creating a new template for each new image, no?

           

          digitalirony can you please verify this? You are generating a new image constantly and want to filter by image family in the configuration for the image you're going to launch your agent with?

          Rachel Yen added a comment - Hmm, it sounds like new images are being generated whenever you run a new job? ingwar I'm not sure we solve that with templates since we would still be creating a new template for each new image, no?   digitalirony can you please verify this? You are generating a new image constantly and want to filter by image family in the configuration for the image you're going to launch your agent with?

          Eric Blackwell added a comment - - edited

          Yes, I am running a job that uses packer.io to build GCE images from a 'recipe' I maintain in a git repo. 

          I eventually want to be able to use my script to build several different flavors of my 'golden image', and tag them all using the os_family.

          Then I can have This plugin always use the latest build automatically from that family. This way I am not constantly having to adjust which image jenkins uses for the slaves/agents. And I can just run my golden image builds, and know that jenkins will always pull the latest from the family specified if that makes sense?

           

          And, no templates is not what I am looking for. zombiemoose

          Eric Blackwell added a comment - - edited Yes, I am running a job that uses packer.io to build GCE images from a 'recipe' I maintain in a git repo.  I eventually want to be able to use my script to build several different flavors of my 'golden image', and tag them all using the os_family. Then I can have This plugin always use the latest build automatically from that family. This way I am not constantly having to adjust which image jenkins uses for the slaves/agents. And I can just run my golden image builds, and know that jenkins will always pull the latest from the family specified if that makes sense?   And, no templates is not what I am looking for. zombiemoose

          Rachel Yen added a comment -

          Ok, I see. I'm not sure how popular this use case would be, and that would affect how I prioritize this feature/if we do implement this feature.

          Rachel Yen added a comment - Ok, I see. I'm not sure how popular this use case would be, and that would affect how I prioritize this feature/if we do implement this feature.

          I bet more people would use it if it was available. Is pretty handy.

          Eric Blackwell added a comment - I bet more people would use it if it was available. Is pretty handy.

          Karol Lassak added a comment -

          digitalirony zombiemoose Thats exactly what Im telling about..

          Thats was one of main reasons to add templates in our company.

           

          At template level you can choose image family instead of image instead of image itself, and every time you create new image in that family it will automatically use it.

          Karol Lassak added a comment - digitalirony zombiemoose  Thats exactly what Im telling about.. Thats was one of main reasons to add templates in our company.   At template level you can choose image family instead of image instead of image itself, and every time you create new image in that family it will automatically use it.

          Rachel Yen added a comment -

          digitalirony Why don't you try out the template first and let me know what you think? I just tried it out via the command line in cloud console, and it did seem to give me the latest image in my image family.

          Example:

          gcloud compute instance-templates create example-template-custom \
              --machine-type n1-standard-4 \
              --image-family jenkins-agent \
              --image-project rach-project \
              --boot-disk-size 250GB
          

           

          ingwar I was trying to create a template from cloud console, but it forces you to provide an image rather than just specifying an image family, so that's interesting. Thanks for your input.

          Rachel Yen added a comment - digitalirony Why don't you try out the template first and let me know what you think? I just tried it out via the command line in cloud console, and it did seem to give me the latest image in my image family. Example: gcloud compute instance-templates create example-template-custom \ --machine-type n1-standard-4 \ --image-family jenkins-agent \ --image-project rach-project \ --boot-disk-size 250GB   ingwar I was trying to create a template from cloud console, but it forces you to provide an image rather than just specifying an image family, so that's interesting. Thanks for your input.

          Karol Lassak added a comment - - edited

          We are using terraform + API directly to create templates (terraform and gcloud dont have such options)..

          And seems like UI have only option to set image..

          But via templates its possible to set every parameter of created machine (At least I did not found any parameter when its not possible)

          Karol Lassak added a comment - - edited We are using terraform + API directly to create templates (terraform and gcloud dont have such options).. And seems like UI have only option to set image.. But via templates its possible to set every parameter of created machine (At least I did not found any parameter when its not possible)

          Rachel Yen added a comment -

          ingwar Great to know. Thanks for your continued contributions! You've really helped us improve the plugin.

          Rachel Yen added a comment - ingwar Great to know. Thanks for your continued contributions! You've really helped us improve the plugin.

            zombiemoose Rachel Yen
            digitalirony Eric Blackwell
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: