Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Subnetwork should not be empty Error

Hello Everyone

I am trying out GCP for the first time. I have an instance of Jenkins set up on my laptop running Windows 10. I am trying to create a Jenkins pipeline that does a Java build and deploys it to GCP. When I try to run the build, I get the following error:

 

 

POST https://compute.googleapis.com/compute/v1/projects/elite-impact-378112/zones/europe-west2-a/instances
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid value for field 'resource.networkInterfaces[0].subnetwork': ''. Subnetwork should not be empty.",
    "reason" : "invalid"
  } ],
  "message" : "Invalid value for field 'resource.networkInterfaces[0].subnetwork': ''. Subnetwork should not be empty."
}

 

 

Looking at the documentation, I discovered that the url for the subnetwork resource ought to have the form

https://www.googleapis.com/compute/v1/projects/project/regions/region/subnetworks/subnetwork

it seems mine is missing the instance/subnetwork at the end. I think this is related to the fact that when I was configuring the Google Compute Engine in my local instance of Jenkins, The dropdown menu labelled "Machine Configuration Template to use" was always empty. I tried every allowable combination of the Region and Zone dropdown menus but the Template menu always came up blank. Please I would be extremely grateful on any pointers as to how to solve this problem.

 

 

0 3 490
3 REPLIES 3

Hello imonike,

There is a Github post with the similar concern and they provided a syntax that can fix the issue

network_interface {
subnetwork = "subnetwork_name"
subnetwork_project ="sharec_vpc_project_name"
}

Thanks dionv for the reply. I am a bit confused here as to how to implement this given that I am making use of the Jenkins GUI to set the config options.

If your dropdown menu Template to use in Machine Configuration is empty, you need to create the Instance template in the Location "Global", otherwise it is not be present in the dropdown.
However to resolve your issue, it should be sufficient to expand the "Advanced" panel under the "Template to use" field and to select existing Network and Subnet in the "Networking" part.