node

[!TIP|label:reference:]

yaml

#!/usr/bin/env groovy

import groovy.transform.Field

@Field final String CLUSTER   = 'DevOps Kubernetes'
@Field final String NAMESPACE = 'devops'
String label                  = env.BUILD_TAG

ansiColor('xterm') { timestamps {
  podTemplate(
    label: label ,
    cloud: CLUSTER ,
    namespace: NAMESPACE ,
    showRawYaml: true,
    yaml: """
      apiVersion: v1
      kind: Pod
      metadata:
        labels:
          jenkins: jnlp-inbound-agent
      spec:
        hostNetwork: true
        nodeSelector:
          <label_name>: "<value>"
        containers:
        - name: jnlp
          image: jenkins/inbound-agent:latest
          workingDir: /home/jenkins
          tty: true
    """
  ) { node (label) { container(name:'jnlp', shell:'/bin/bash') {
      stage('prepare') {
        sh """
          whoami
          pwd
          realpath ${WORKSPACE}
        """
      } // stage
  }}} // container | node | podTemplate
}} // timestamp | ansiColor

// vim: ft=Jenkinsfile ts=2 sts=2 sw=2 et

with resources

with POD_LABEL

default yaml

  • windows (kubernetes)

    [!TIP|label:windows pod:]

  • maven (kubernetes)

container

multiple containerTemplate with resource limits

[!NOTE|label:add memory and cpu resources in containerTemplate:]

Last updated

Was this helpful?