How can I pass a gradle property to jib via skaffold

91 Views Asked by At

I have a gradle build file with the following jib definition:

def baseImage = 'ghcr.io/tobias-neubert/eclipse-temurin:17.0.2_8-jre'
jib {
  from {
    image = baseImage
    auth {
      username = githubUser
      password = githubPassword
    }
  }
  to {
    image = 'ghcr.io/tobias-neubert/motd-service:0.0.1'
    auth {
      username = githubUser
      password = githubPassword
    }
  }
}

and the following skaffold.yaml:

apiVersion: skaffold/v4beta1
kind: Config
metadata:
  name: motd-service
build:
  artifacts:
    - image: ghcr.io/tobias-neubert/motd-service
      jib:
        args:
          - "-PgithubUser=tobias-neubert"
          - "-PgithubPassword=secret"
manifests:
  rawYaml:
    - k8s/deployment.yaml
    - k8s/istio.yaml

It seems that the arguments are not passed to gradle because I get the error:

Could not get unknown property 'githubPassword'

Why? What am I doing wrong and/or what have I misunderstood?

1

There are 1 best solutions below

0
On

If I define the property like so:

ext {
  githubPassword = System.getProperty('githubPassword', '')
}

I have to pass that property as system property vi -DgithubPassword not as -P