I've created a Jenkins pipeline and I am running it on GKE (using Kubernetes plugin). In one of the steps I am running java application in one of the containers. Application is writing logs to stdout. I would like to see the logs from this application in Stackdriver. How can I achieve it? Currently I am not able to see these logs in Stackdriver nor in Jenkins logs.
My pipeline:
podTemplate(cloud: 'kubernetes',
yaml: """
apiVersion: v1
kind: Pod
spec:
securityContext:
runAsUser: 0
containers:
- name: maven
image: maven:3.6.3-jdk-11
resources:
requests:
cpu: "1"
memory: "1Gi"
ephemeral-storage: "20Mi"
limits:
cpu: "2"
memory: "4Gi"
ephemeral-storage: "1Gi"
command:
- cat
tty: true
"""
) {
node(POD_LABEL) {
stage('Run app') {
container('maven') {
sh "java -jar my-app.jar &"
}
}
}
}
=== EDIT ===
My master Jenkins is installed on one of the GKE pods and each PR validation triggers another pod having the mentioned container with java application. It looks that the jenkins slave agent is gathering the logs (but not attaching them to build log as the java app is run in background).