├── .dockerignore ├── .git-blame-ignore-revs ├── .github ├── CODEOWNERS ├── autolabeler.yaml ├── dependabot.yml ├── release-drafter.yml ├── renovate.json └── workflows │ ├── cd.yaml │ └── jenkins-security-scan.yml ├── .gitignore ├── .mvn ├── extensions.xml └── maven.config ├── CHANGELOG-archive.md ├── Dockerfile ├── Jenkinsfile ├── LICENSE ├── README.md ├── README_zh.md ├── configuration.png ├── credentials.png ├── examples ├── README.md ├── containerLog.groovy ├── declarative_from_yaml_file │ ├── Jenkinsfile │ └── KubernetesPod.yaml ├── dind.groovy ├── dood.groovy ├── kaniko-declarative.groovy ├── kaniko-gcr.groovy ├── kaniko.groovy ├── maven-with-cache-pvc.yml ├── maven-with-cache.groovy ├── multi-container.groovy ├── openshift-home-yaml.groovy └── selenium.groovy ├── images ├── cloud-configuration.png ├── garbage-collection.png ├── mypod-1-general.png ├── mypod-2-golang.png ├── mypod-3-maven.png └── pod-template-configuration.png ├── kind-preload.sh ├── kind.sh ├── pom.xml └── src ├── main ├── docker │ └── master-executors.groovy ├── java │ ├── io │ │ └── jenkins │ │ │ └── plugins │ │ │ └── kubernetes │ │ │ └── NoDelayProvisionerStrategy.java │ └── org │ │ └── csanchez │ │ └── jenkins │ │ └── plugins │ │ └── kubernetes │ │ ├── ContainerEnvVar.java │ │ ├── ContainerLivenessProbe.java │ │ ├── ContainerTemplate.java │ │ ├── DefaultInProvisioning.java │ │ ├── GarbageCollection.java │ │ ├── InProvisioning.java │ │ ├── KubectlBuildWrapper.java │ │ ├── KubernetesClientProvider.java │ │ ├── KubernetesCloud.java │ │ ├── KubernetesComputer.java │ │ ├── KubernetesComputerFactory.java │ │ ├── KubernetesFactoryAdapter.java │ │ ├── KubernetesFolderProperty.java │ │ ├── KubernetesLauncher.java │ │ ├── KubernetesProvisioningLimits.java │ │ ├── KubernetesQueueTaskDispatcher.java │ │ ├── KubernetesSlave.java │ │ ├── LimitRegistrationResults.java │ │ ├── MetricNames.java │ │ ├── NonConfigurableKubernetesCloud.java │ │ ├── OpenShiftBearerTokenCredentialImpl.java │ │ ├── OpenShiftTokenCredentialImpl.java │ │ ├── PlannedNodeBuilder.java │ │ ├── PlannedNodeBuilderFactory.java │ │ ├── PodAnnotation.java │ │ ├── PodContainerSource.java │ │ ├── PodEnvVar.java │ │ ├── PodImagePullSecret.java │ │ ├── PodLabel.java │ │ ├── PodTemplate.java │ │ ├── PodTemplateBuilder.java │ │ ├── PodTemplateFilter.java │ │ ├── PodTemplateGroup.java │ │ ├── PodTemplateLabelFilter.java │ │ ├── PodTemplateSource.java │ │ ├── PodTemplateToolLocation.java │ │ ├── PodTemplateUtils.java │ │ ├── PodUtils.java │ │ ├── PodVolumes.java │ │ ├── PortMapping.java │ │ ├── RestrictedPssSecurityContextInjector.java │ │ ├── Serialization2.java │ │ ├── ServiceAccountCredential.java │ │ ├── StandardPlannedNodeBuilder.java │ │ ├── TaskListenerEventWatcher.java │ │ ├── TokenProducer.java │ │ ├── model │ │ ├── KeyValueEnvVar.java │ │ ├── SecretEnvVar.java │ │ └── TemplateEnvVar.java │ │ ├── pipeline │ │ ├── AbstractInvisibleRunAction2.java │ │ ├── Constants.java │ │ ├── ContainerExecDecorator.java │ │ ├── ContainerExecProc.java │ │ ├── ContainerLogStep.java │ │ ├── ContainerLogStepExecution.java │ │ ├── ContainerStep.java │ │ ├── ContainerStepExecution.java │ │ ├── KubernetesAgentErrorCondition.java │ │ ├── KubernetesDeclarativeAgent.java │ │ ├── KubernetesNodeContext.java │ │ ├── KubernetesSamples.java │ │ ├── NamespaceAction.java │ │ ├── PodTemplateAction.java │ │ ├── PodTemplateContext.java │ │ ├── PodTemplateMap.java │ │ ├── PodTemplateStep.java │ │ ├── PodTemplateStepExecution.java │ │ ├── Resources.java │ │ └── SecretsMasker.java │ │ ├── pod │ │ ├── decorator │ │ │ ├── DefaultNodeSelector.java │ │ │ ├── DefaultRestartPolicy.java │ │ │ ├── DefaultWorkspaceVolume.java │ │ │ ├── PodDecorator.java │ │ │ └── PodDecoratorException.java │ │ ├── retention │ │ │ ├── Always.java │ │ │ ├── Default.java │ │ │ ├── Never.java │ │ │ ├── OnFailure.java │ │ │ ├── PodOfflineCause.java │ │ │ ├── PodRetention.java │ │ │ ├── PodRetentionDescriptor.java │ │ │ └── Reaper.java │ │ └── yaml │ │ │ ├── Merge.java │ │ │ ├── Overrides.java │ │ │ └── YamlMergeStrategy.java │ │ ├── volumes │ │ ├── ConfigMapVolume.java │ │ ├── DynamicPVC.java │ │ ├── DynamicPVCVolume.java │ │ ├── EmptyDirVolume.java │ │ ├── EphemeralVolume.java │ │ ├── GenericEphemeralVolume.java │ │ ├── HostPathVolume.java │ │ ├── NfsVolume.java │ │ ├── PVCVolumeUtils.java │ │ ├── PersistentVolumeClaim.java │ │ ├── PodVolume.java │ │ ├── ProvisionedVolume.java │ │ ├── SecretVolume.java │ │ └── workspace │ │ │ ├── DynamicPVCWorkspaceVolume.java │ │ │ ├── EmptyDirWorkspaceVolume.java │ │ │ ├── GenericEphemeralWorkspaceVolume.java │ │ │ ├── HostPathWorkspaceVolume.java │ │ │ ├── NfsWorkspaceVolume.java │ │ │ ├── PersistentVolumeClaimWorkspaceVolume.java │ │ │ └── WorkspaceVolume.java │ │ └── watch │ │ └── PodStatusEventHandler.java ├── kubernetes │ ├── jenkins.yml │ └── service-account.yml ├── resources │ ├── index.jelly │ └── org │ │ └── csanchez │ │ └── jenkins │ │ └── plugins │ │ └── kubernetes │ │ ├── ContainerLivenessProbe │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-execArgs.html │ │ ├── help-failureThreshold.html │ │ ├── help-initialDelaySeconds.html │ │ ├── help-periodSeconds.html │ │ ├── help-successThreshold.html │ │ └── help-timeoutSeconds.html │ │ ├── ContainerTemplate │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-alwaysPullImage.html │ │ ├── help-args.html │ │ ├── help-command.html │ │ ├── help-envVars.html │ │ ├── help-image.html │ │ ├── help-name.html │ │ ├── help-privileged.html │ │ ├── help-resourceLimitCpu.html │ │ ├── help-resourceLimitMemory.html │ │ ├── help-resourceRequestCpu.html │ │ ├── help-resourceRequestMemory.html │ │ ├── help-runAsGroup.html │ │ ├── help-runAsUser.html │ │ ├── help-ttyEnabled.html │ │ └── help-workingDir.html │ │ ├── Dockerfile │ │ ├── GarbageCollection │ │ ├── config.jelly │ │ └── help-namespaces.html │ │ ├── KubectlBuildWrapper │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-caCertificate.html │ │ ├── help-serverUrl.html │ │ └── help.html │ │ ├── KubernetesCloud │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-addMasterProxyEnvVars.html │ │ ├── help-connectTimeout.html │ │ ├── help-containerCapStr.html │ │ ├── help-defaultsProviderTemplate.html │ │ ├── help-directConnection.html │ │ ├── help-garbageCollection.html │ │ ├── help-jenkinsTunnel.html │ │ ├── help-jenkinsUrl.html │ │ ├── help-jnlpregistry.html │ │ ├── help-maxRequestsPerHostStr.html │ │ ├── help-name.html │ │ ├── help-password.html │ │ ├── help-podLabels.html │ │ ├── help-podRetention.html │ │ ├── help-readTimeout.html │ │ ├── help-restrictedPssSecurityContext.html │ │ ├── help-retentionTimeout.html │ │ ├── help-serverCertificate.html │ │ ├── help-serverUrl.html │ │ ├── help-skipTlsVerify.html │ │ ├── help-usageRestricted.html │ │ ├── help-useJenkinsProxy.html │ │ ├── help-username.html │ │ ├── help-waitForPodSec.html │ │ ├── help-webSocket.html │ │ ├── new.jelly │ │ ├── sidepanel.jelly │ │ ├── sidepanel.properties │ │ └── templates.jelly │ │ ├── KubernetesComputer │ │ ├── container.jelly │ │ ├── events.jelly │ │ ├── podLog.jelly │ │ └── sidepanel2.jelly │ │ ├── KubernetesFolderProperty │ │ ├── config.jelly │ │ └── config_zh_CN.properties │ │ ├── KubernetesSlave │ │ ├── configure-entries.jelly │ │ └── configure-entries_zh_CN.properties │ │ ├── Messages.properties │ │ ├── Messages_zh_CN.properties │ │ ├── NonConfigurableKubernetesCloud │ │ └── config.jelly │ │ ├── PodAnnotation │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-key.html │ │ └── help-value.html │ │ ├── PodImagePullSecret │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ └── help-name.html │ │ ├── PodLabel │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-key.html │ │ └── help-value.html │ │ ├── PodTemplate │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-activeDeadlineSeconds.html │ │ ├── help-agentContainer.html │ │ ├── help-agentInjection.html │ │ ├── help-annotations.html │ │ ├── help-containers.html │ │ ├── help-envVars.html │ │ ├── help-hostNetwork.html │ │ ├── help-idleMinutes.html │ │ ├── help-imagePullSecrets.html │ │ ├── help-inheritFrom.html │ │ ├── help-inheritYamlMergeStrategy.html │ │ ├── help-instanceCap.html │ │ ├── help-label.html │ │ ├── help-name.html │ │ ├── help-namespace.html │ │ ├── help-nodeSelector.html │ │ ├── help-podRetention.html │ │ ├── help-runAsGroup.html │ │ ├── help-runAsUser.html │ │ ├── help-serviceAccount.html │ │ ├── help-showRawYaml.html │ │ ├── help-slaveConnectTimeout.html │ │ ├── help-supplementalGroups.html │ │ ├── help-volumes.html │ │ ├── help-workingDir.html │ │ ├── help-workspaceVolume.html │ │ ├── help-yaml.html │ │ ├── help-yamlMergeStrategy.html │ │ ├── index.jelly │ │ ├── sidepanel.jelly │ │ └── sidepanel.properties │ │ ├── PortMapping │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-containerPort.html │ │ ├── help-hostPort.html │ │ └── help-name.html │ │ ├── ServiceAccountCredential │ │ └── credentials.jelly │ │ ├── model │ │ ├── KeyValueEnvVar │ │ │ ├── config.jelly │ │ │ ├── config_zh_CN.properties │ │ │ ├── help-key.html │ │ │ └── help-value.html │ │ └── SecretEnvVar │ │ │ ├── config.jelly │ │ │ ├── config_zh_CN.properties │ │ │ ├── help-key.html │ │ │ ├── help-optional.html │ │ │ ├── help-secretKey.html │ │ │ └── help-secretName.html │ │ ├── pipeline │ │ ├── ContainerLogStep │ │ │ ├── config.jelly │ │ │ ├── help-limitBytes.html │ │ │ ├── help-name.html │ │ │ ├── help-returnLog.html │ │ │ ├── help-sinceSeconds.html │ │ │ └── help-tailingLines.html │ │ ├── ContainerStep │ │ │ ├── config.jelly │ │ │ ├── help-shell.html │ │ │ └── help.html │ │ ├── KubernetesAgentErrorCondition │ │ │ ├── config.jelly │ │ │ ├── help-handleNonKubernetes.html │ │ │ └── help.html │ │ ├── KubernetesDeclarativeAgent │ │ │ ├── config.jelly │ │ │ ├── help-customWorkspace.html │ │ │ └── help-defaultContainer.html │ │ ├── KubernetesDeclarativeAgentScript-old.groovy │ │ ├── KubernetesDeclarativeAgentScript.groovy │ │ ├── Messages.properties │ │ ├── PodTemplateStep │ │ │ ├── config.jelly │ │ │ ├── help-cloud.html │ │ │ ├── help-label.html │ │ │ └── help.html │ │ └── samples │ │ │ ├── declarative.groovy │ │ │ ├── maven.groovy │ │ │ └── windows.groovy │ │ ├── pod │ │ ├── retention │ │ │ ├── Messages.properties │ │ │ └── Messages_zh_CN.properties │ │ └── yaml │ │ │ ├── Merge │ │ │ └── config.jelly │ │ │ └── Overrides │ │ │ └── config.jelly │ │ └── volumes │ │ ├── ConfigMapVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-configMapName.html │ │ └── help-optional.html │ │ ├── DynamicPVCVolume │ │ └── config.jelly │ │ ├── EmptyDirVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ └── help-memory.html │ │ ├── GenericEphemeralVolume │ │ └── config.jelly │ │ ├── HostPathVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-hostPath.html │ │ └── help-readOnly.html │ │ ├── NfsVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-serverAddress.html │ │ └── help-serverPath.html │ │ ├── PersistentVolumeClaim │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-claimName.html │ │ └── help-readOnly.html │ │ ├── PodVolume │ │ ├── help-accessModes.html │ │ ├── help-mountPath.html │ │ ├── help-requestsSize.html │ │ ├── help-storageClassName.html │ │ └── help-subPath.html │ │ ├── SecretVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-defaultMode.html │ │ ├── help-optional.html │ │ └── help-secretName.html │ │ └── workspace │ │ ├── DynamicPVCWorkspaceVolume │ │ └── config.jelly │ │ ├── EmptyDirWorkspaceVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-memory.html │ │ └── help-sizeLimit.html │ │ ├── GenericEphemeralWorkspaceVolume │ │ └── config.jelly │ │ ├── HostPathWorkspaceVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ └── help-hostPath.html │ │ ├── NfsWorkspaceVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-serverAddress.html │ │ └── help-serverPath.html │ │ ├── PersistentVolumeClaimWorkspaceVolume │ │ ├── config.jelly │ │ ├── config_zh_CN.properties │ │ ├── help-claimName.html │ │ └── help-readOnly.html │ │ └── WorkspaceVolume │ │ ├── help-accessModes.html │ │ ├── help-requestsSize.html │ │ └── help-storageClassName.html └── webapp │ └── images │ ├── 24x24 │ └── kubernetes.png │ ├── 32x32 │ └── kubernetes.png │ └── 48x48 │ └── kubernetes.png ├── spotbugs └── excludesFilter.xml └── test ├── java └── org │ └── csanchez │ └── jenkins │ └── plugins │ └── kubernetes │ ├── AbstractGoldenFileTest.java │ ├── ConfigMapVolumeTest.java │ ├── ContainerTemplateTest.java │ ├── KubectlBuildWrapperTest.java │ ├── KubernetesClientProviderTest.java │ ├── KubernetesCloudFIPSTest.java │ ├── KubernetesCloudTest.java │ ├── KubernetesFactoryAdapterTest.java │ ├── KubernetesFolderPropertyTest.java │ ├── KubernetesProvisioningLimitsTest.java │ ├── KubernetesQueueTaskDispatcherTest.java │ ├── KubernetesRestartTest.java │ ├── KubernetesSlaveTest.java │ ├── KubernetesTest.java │ ├── KubernetesTestUtil.java │ ├── MetricNamesTest.java │ ├── NonConfigurableKubernetesCloudTest.java │ ├── PodContainerSourceTest.java │ ├── PodEnvVarTest.java │ ├── PodTemplateBuilderTest.java │ ├── PodTemplateFilterTest.java │ ├── PodTemplateJenkinsTest.java │ ├── PodTemplateMapTest.java │ ├── PodTemplateTest.java │ ├── PodTemplateUtilsTest.java │ ├── PodUtilsTest.java │ ├── RestrictedPssSecurityInjectorTest.java │ ├── TaskListenerEventWatcherTest.java │ ├── casc │ ├── CasCTest.java │ ├── EnvVarCasCTest.java │ ├── VolumeCasCTest.java │ └── WorkspaceVolumeCasCTest.java │ ├── pipeline │ ├── AbstractKubernetesPipelineRJRTest.java │ ├── AbstractKubernetesPipelineTest.java │ ├── ContainerExecDecoratorPipelineTest.java │ ├── ContainerExecDecoratorTest.java │ ├── ContainerExecDecoratorWindowsTest.java │ ├── ContainerLogStepTest.java │ ├── DirectConnectionTest.java │ ├── KubernetesAgentErrorConditionTest.java │ ├── KubernetesDeclarativeAgentRJRTest.java │ ├── KubernetesDeclarativeAgentTest.java │ ├── KubernetesDeclarativeAgentUnitTest.java │ ├── KubernetesNodeContextTest.java │ ├── KubernetesPipelineOverridenNamespaceTest.java │ ├── KubernetesPipelineRJRTest.java │ ├── KubernetesPipelineTest.java │ ├── KubernetesPipelineWebsocketRJRTest.java │ ├── KubernetesSamplesTest.java │ ├── NoDelayProvisionerStrategyTest.java │ ├── PodNameTest.java │ ├── PodProvisioningStatusLogsTest.java │ ├── PodTemplateStepExecutionTest.java │ ├── PodTemplateStepTest.java │ ├── ResourcesTest.java │ ├── RestartPipelineTest.java │ ├── WebSocketTest.java │ └── steps │ │ ├── AssertBuildLogMessage.java │ │ ├── AssertBuildStatusSuccess.java │ │ ├── CreateWorkflowJobThenScheduleRun.java │ │ ├── CreateWorkflowJobThenScheduleTask.java │ │ ├── RunId.java │ │ ├── SetupCloud.java │ │ └── package-info.java │ ├── pod │ ├── decorator │ │ └── PodDecoratorTest.java │ └── retention │ │ ├── PodRetentionTest.java │ │ └── ReaperTest.java │ └── volumes │ ├── GenericEphemeralVolumeTest.java │ └── workspace │ └── GenericEphemeralWorkspaceVolumeTest.java └── resources ├── kubenamespace ├── mockito-extensions └── org.mockito.plugins.MockMaker └── org └── csanchez └── jenkins └── plugins └── kubernetes ├── KubernetesCloudFIPSTest ├── certs │ ├── dsa1024 │ ├── dsa2048 │ ├── ecdsa192 │ ├── ecdsa224 │ ├── not-a-cert │ ├── rsa1024 │ └── rsa2048 └── nonCompliantCloudsAreCleanedTest │ └── config.xml ├── KubernetesCloudTest ├── emptyKubernetesCloudReadResolve │ └── config.xml └── readResolveContainerCapZero │ └── config.xml ├── KubernetesRestartTest └── upgradeFrom_1_27_1 │ └── config.xml ├── KubernetesTest ├── upgradeFrom_0_10 │ └── config.xml ├── upgradeFrom_0_12 │ └── config.xml ├── upgradeFrom_0_8 │ └── config.xml ├── upgradeFrom_1_1 │ ├── config.xml │ └── credentials.xml ├── upgradeFrom_1_10 │ ├── config.xml │ └── credentials.xml ├── upgradeFrom_1_15_1 │ ├── config.xml │ └── credentials.xml ├── upgradeFrom_1_15_9 │ └── config.xml ├── upgradeFrom_1_15_9_invalid │ └── config.xml └── upgradeFrom_1_17_2 │ ├── config.xml │ └── credentials.xml ├── PodTemplateUtilsTest ├── decimal.yaml └── octal.yaml ├── RestrictedPssSecurityInjectorTest ├── agentInjection-after.yaml ├── agentInjection-before.yaml ├── existingSecurityContext-after.yaml ├── existingSecurityContext-before.yaml ├── multiContainer-after.yaml ├── multiContainer-before.yaml ├── simple-after.yaml └── simple-before.yaml ├── casc ├── casc_envVar_keyValue.yaml ├── casc_envVar_secret.yaml ├── casc_volume_configMap.yaml ├── casc_volume_emptyDir.yaml ├── casc_volume_emptyDir_memory.yaml ├── casc_volume_genericEphemeral.yaml ├── casc_volume_hostPath.yaml ├── casc_volume_nfs.yaml ├── casc_volume_pvc.yaml ├── casc_workspaceVolume_dynamicPVC.yaml ├── casc_workspaceVolume_emptyDir.yaml ├── casc_workspaceVolume_emptyDir_memory.yaml ├── casc_workspaceVolume_genericEphemeral.yaml ├── casc_workspaceVolume_hostPath.yaml ├── casc_workspaceVolume_nfs.yaml ├── casc_workspaceVolume_pvc.yaml └── configuration-as-code.yaml ├── kubectlBuildWrapper_invalidCredentials.groovy ├── kubectlBuildWrapper_missingCredentials.groovy ├── pipeline ├── badcontainername.groovy ├── badcontainernameyaml.groovy ├── basicPipeline.groovy ├── basicWindows.groovy ├── bourneShellElsewhereInPath.groovy ├── cancelOnlyRelevantQueueItem.groovy ├── cascadingDelete.groovy ├── closedWebSocketExit.groovy ├── computerCantBeConfigured.groovy ├── containerEnvironmentIsHonored.groovy ├── containerStatusErrorLogs.groovy ├── containerTerminated.groovy ├── declarative.groovy ├── declarativeCustomWorkingDir.groovy ├── declarativeCustomWorkspace.groovy ├── declarativeFromYaml.groovy ├── declarativeFromYamlFile.groovy ├── declarativeFromYamlWithNullEnv.groovy ├── declarativeRetries.groovy ├── declarativeShowRawYamlFalse.groovy ├── declarativeWithCreateContainerError.groovy ├── declarativeWithNamespaceFromYaml.groovy ├── declarativeWithNestedExplicitInheritance.groovy ├── declarativeWithNonexistentDockerImage.groovy ├── declarativeYamlFile.yml ├── decoratorFailure.groovy ├── directConnectionAgent.groovy ├── docker.groovy ├── dynamicPVCVolume.groovy ├── dynamicPVCWorkspaceVolume.groovy ├── envVarDollarSignEscaping.groovy ├── errorPod.groovy ├── garbageCollection.groovy ├── getContainerLog.groovy ├── getContainerLogWithRestart.groovy ├── handleEviction.groovy ├── id_rsa ├── imageWithoutAgent.groovy ├── imageWithoutAgentNoJava.groovy ├── inheritFrom.groovy ├── interruptedPod.groovy ├── interruptedPodWindows.groovy ├── invalidImageGetsCancelled.groovy ├── invalidPodGetsCancelled.groovy ├── jenkinsSecretHidden.groovy ├── jnlpWorkingDir.groovy ├── mergeYaml.groovy ├── noDelayProvisionerCallsListener.groovy ├── nullLabelSupportsRestart.groovy ├── octalPermissions.groovy ├── overrideYaml.groovy ├── podDeadlineExceeded.groovy ├── podDeadlineExceededGlobalTemplate.groovy ├── podStatusErrorLogs.groovy ├── podStatusNoErrorLogs.groovy ├── podTemplateWithMultipleLabels.groovy ├── restartDuringPodLaunch.groovy ├── runDirContext.groovy ├── runIn2Pods.groovy ├── runInDynamicallyCreatedContainer.groovy ├── runInPod.groovy ├── runInPodFromYaml.groovy ├── runInPodNested.groovy ├── runInPodNestedExplicitInherit.groovy ├── runInPodWithDifferentShell.groovy ├── runInPodWithExistingTemplate.groovy ├── runInPodWithLivenessProbe.groovy ├── runInPodWithMultipleContainers.groovy ├── runInPodWithRestart.groovy ├── runInPodWithRestartWithLongSleep.groovy ├── runInPodWithRestartWithMultipleContainerCalls.groovy ├── runInPodWithRetention.groovy ├── runInPodWithShowRawYamlFalse.groovy ├── runWithActiveDeadlineSeconds.groovy ├── runWithCloudOverriddenNamespace.groovy ├── runWithEnvVariables.groovy ├── runWithEnvVariablesInContext.groovy ├── runWithOverriddenEnvVariables.groovy ├── runWithStepOverriddenNamespace.groovy ├── secretMaskingWindows.groovy ├── showRawYamlFalseInherited.groovy ├── sidecarWorkingDir.groovy ├── sshagent.groovy ├── substituteEnv.groovy ├── supportComputerEnvVars.groovy ├── taskListenerAfterRestart.groovy ├── taskListenerAfterRestart_multipleLabels.groovy ├── terminatedPod.groovy ├── terminatedPodAfterRestart.groovy ├── webSocketAgent.groovy ├── windowsContainer.groovy └── windowsRestart.groovy ├── pod-busybox.yaml ├── pod-jnlp-nullenv.yaml └── pod-overrides.yaml /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | work 3 | target 4 | !target/kubernetes.hpi 5 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # https://github.com/jenkinsci/kubernetes-plugin/pull/1478 2 | 9c1d58d9badd988622b4772632037126176e1ef0 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @jenkinsci/kubernetes-plugin-developers 2 | -------------------------------------------------------------------------------- /.github/autolabeler.yaml: -------------------------------------------------------------------------------- 1 | documentation: ["README*", "/examples"] 2 | chore: ["/.github", "/.mvn"] 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | - package-ecosystem: docker 9 | directory: '/src/main/resources/org/csanchez/jenkins/plugins/kubernetes' 10 | # TODO https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#ignore as needed to accept only *-jdk11 11 | schedule: 12 | interval: 'daily' 13 | - package-ecosystem: github-actions 14 | directory: / 15 | schedule: 16 | interval: weekly 17 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | _extends: .github 2 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ], 6 | "labels": [ 7 | "dependencies" 8 | ], 9 | "packageRules": [ 10 | { 11 | "description": "remoting agent uses non-standard versioning", 12 | "matchDatasources": ["docker"], 13 | "matchPackageNames": ["jenkins/inbound-agent"], 14 | "versioning": "regex:^(?\\d+)\\.(?[^\\.-]*)(\\.(?\\d+))?(-(?\\d+))?$" 15 | } 16 | ], 17 | "enabledManagers": [ 18 | "dockerfile", 19 | "docker-compose", 20 | "kubernetes" 21 | ], 22 | "dockerfile": { 23 | "fileMatch": [ 24 | ".*\\.dockerfile$", 25 | ".*-dockerfile$", 26 | "Dockerfile" 27 | ] 28 | }, 29 | "kubernetes": { 30 | "fileMatch": [ 31 | ".*\\.ya?ml$" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/cd.yaml: -------------------------------------------------------------------------------- 1 | # Note: additional setup is required, see https://www.jenkins.io/redirect/continuous-delivery-of-plugins 2 | 3 | name: cd 4 | on: 5 | workflow_dispatch: 6 | check_run: 7 | types: 8 | - completed 9 | 10 | jobs: 11 | maven-cd: 12 | uses: jenkins-infra/github-reusable-workflows/.github/workflows/maven-cd.yml@v1 13 | secrets: 14 | MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} 15 | MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }} 16 | -------------------------------------------------------------------------------- /.github/workflows/jenkins-security-scan.yml: -------------------------------------------------------------------------------- 1 | name: Jenkins Security Scan 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | types: [ opened, synchronize, reopened ] 9 | workflow_dispatch: 10 | 11 | permissions: 12 | security-events: write 13 | contents: read 14 | actions: read 15 | 16 | jobs: 17 | security-scan: 18 | uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2 19 | with: 20 | java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate. 21 | # java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.project 4 | /.factorypath 5 | /.settings/ 6 | /work/ 7 | /.idea/ 8 | *.iml 9 | nbactions.xml 10 | nb-configuration.xml 11 | *.bak 12 | /.vscode/ 13 | **/.DS_Store 14 | -------------------------------------------------------------------------------- /.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | io.jenkins.tools.incrementals 4 | git-changelist-maven-extension 5 | 1.8 6 | 7 | 8 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Pconsume-incrementals 2 | -Pmight-produce-incrementals 3 | -Dchangelist.format=%d.v%s 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jenkins/jenkins:lts-alpine 2 | 3 | ARG VERSION=1.15.5 4 | #RUN /usr/local/bin/install-plugins.sh kubernetes:${VERSION} 5 | 6 | RUN jenkins-plugin-cli --plugins kubernetes-client-api \ 7 | kubernetes-credentials \ 8 | docker-commons \ 9 | cloudbees-folder \ 10 | workflow-api \ 11 | variant \ 12 | durable-task \ 13 | workflow-durable-task-step \ 14 | metrics \ 15 | caffeine-api 16 | COPY target/kubernetes.hpi /usr/share/jenkins/ref/plugins/kubernetes.hpi 17 | 18 | # RUN curl -o /usr/share/jenkins/ref/plugins/kubernetes.hpi \ 19 | # http://repo.jenkins-ci.org/snapshots/org/csanchez/jenkins/plugins/kubernetes/0.12/kubernetes-$VERSION.hpi 20 | 21 | # remove executors in controller 22 | COPY src/main/docker/master-executors.groovy /usr/share/jenkins/ref/init.groovy.d/ 23 | 24 | # ENV JAVA_OPTS="-Djava.util.logging.config.file=/var/jenkins_home/log.properties" 25 | ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -XshowSettings:vm" 26 | -------------------------------------------------------------------------------- /configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/configuration.png -------------------------------------------------------------------------------- /credentials.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/credentials.png -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes plugin Pipeline examples 2 | 3 | In this directory you can find several Pipeline examples. 4 | 5 | For more examples that are automatically tested, check: 6 | 7 | * [live samples](../src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/samples) 8 | * [test scripts](../src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline) 9 | -------------------------------------------------------------------------------- /examples/containerLog.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | some-label: some-label-value 7 | spec: 8 | containers: 9 | - name: maven 10 | image: maven:3.8.1-jdk-8 11 | command: 12 | - sleep 13 | args: 14 | - 99d 15 | tty: true 16 | - name: mongo 17 | image: mongo 18 | ''') { 19 | node(POD_LABEL) { 20 | stage('Integration Test') { 21 | try { 22 | container('maven') { 23 | sh 'nc -z localhost:27017 && echo "connected to mongo db"' 24 | // sh 'mvn -B clean failsafe:integration-test' // real integration test 25 | 26 | def mongoLog = containerLog(name: 'mongo', returnLog: true, tailingLines: 5, sinceSeconds: 20, limitBytes: 50000) 27 | assert mongoLog.contains('connection accepted from 127.0.0.1:') 28 | sh 'echo failing build; false' 29 | } 30 | } catch (Exception e) { 31 | containerLog 'mongo' 32 | throw e 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/declarative_from_yaml_file/Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yamlFile 'examples/declarative_from_yaml_file/KubernetesPod.yaml' 5 | } 6 | } 7 | stages { 8 | stage('Run maven') { 9 | steps { 10 | sh 'set' 11 | sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}" 12 | container('maven') { 13 | sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 14 | sh 'mvn -version' 15 | } 16 | container('busybox') { 17 | sh 'echo BUSYBOX_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 18 | sh '/bin/busybox' 19 | } 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /examples/declarative_from_yaml_file/KubernetesPod.yaml: -------------------------------------------------------------------------------- 1 | metadata: 2 | labels: 3 | some-label: some-label-value 4 | spec: 5 | containers: 6 | - name: jnlp 7 | env: 8 | - name: CONTAINER_ENV_VAR 9 | value: jnlp 10 | - name: maven 11 | image: maven:3.8.1-jdk-8 12 | command: 13 | - sleep 14 | args: 15 | - 99d 16 | env: 17 | - name: CONTAINER_ENV_VAR 18 | value: maven 19 | - name: busybox 20 | image: busybox 21 | command: 22 | - cat 23 | tty: true 24 | env: 25 | - name: CONTAINER_ENV_VAR 26 | value: busybox 27 | -------------------------------------------------------------------------------- /examples/dood.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | “Docker-outside-of-Docker”: runs a Docker-based build by connecting a Docker client inside the pod to the host daemon. 3 | */ 4 | podTemplate(yaml: ''' 5 | apiVersion: v1 6 | kind: Pod 7 | spec: 8 | containers: 9 | - name: docker 10 | image: docker:19.03.1 11 | command: 12 | - sleep 13 | args: 14 | - 99d 15 | volumeMounts: 16 | - name: dockersock 17 | mountPath: /var/run/docker.sock 18 | volumes: 19 | - name: dockersock 20 | hostPath: 21 | path: /var/run/docker.sock 22 | ''') { 23 | node(POD_LABEL) { 24 | stage('Build Docker image') { 25 | git 'https://github.com/jenkinsci/docker-inbound-agent.git' 26 | container('docker') { 27 | sh 'docker build -t jenkins/inbound-agent .' 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/maven-with-cache-pvc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: PersistentVolumeClaim 4 | metadata: 5 | name: maven-repo 6 | namespace: kubernetes-plugin 7 | spec: 8 | accessModes: 9 | - ReadWriteOnce 10 | resources: 11 | requests: 12 | storage: 10Gi 13 | -------------------------------------------------------------------------------- /examples/maven-with-cache.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * This pipeline will execute a simple maven build, using a Persistent Volume Claim to store the local Maven repository 3 | * 4 | * A PersistentVolumeClaim needs to be created ahead of time with the definition in maven-with-cache-pvc.yml 5 | * 6 | * NOTE that typically writable volumes can only be attached to one Pod at a time, so you can't execute 7 | * two concurrent jobs with this pipeline. Or change readOnly: true after the first run 8 | */ 9 | 10 | podTemplate(agentContainer: 'maven', agentInjection: true, containers: [ 11 | containerTemplate(name: 'maven', image: 'maven:3.9.9-eclipse-temurin-17') 12 | ], volumes: [genericEphemeralVolume(accessModes: 'ReadWriteOnce', mountPath: '/root/.m2/repository', requestsSize: '1Gi')]) { 13 | 14 | node(POD_LABEL) { 15 | stage('Build a Maven project') { 16 | git 'https://github.com/jenkinsci/kubernetes-plugin.git' 17 | sh 'mvn -B -ntp clean package -DskipTests' 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/multi-container.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * This pipeline describes a multi container job, running Maven and Golang builds 3 | */ 4 | 5 | podTemplate(agentContainer: 'maven', 6 | agentInjection: true, 7 | yaml: ''' 8 | apiVersion: v1 9 | kind: Pod 10 | spec: 11 | containers: 12 | - name: maven 13 | image: maven:3.9.9-eclipse-temurin-17 14 | - name: golang 15 | image: golang:1.23.1-bookworm 16 | command: 17 | - sleep 18 | args: 19 | - 99d 20 | ''' 21 | ) { 22 | node(POD_LABEL) { 23 | stage('Build a Maven project') { 24 | git 'https://github.com/jenkinsci/kubernetes-plugin.git' 25 | sh 'mvn -B -ntp clean package -DskipTests' 26 | } 27 | stage('Build a Golang project') { 28 | git url: 'https://github.com/hashicorp/terraform.git', branch: 'main' 29 | container('golang') { 30 | sh ''' 31 | mkdir -p /go/src/github.com/hashicorp 32 | ln -s `pwd` /go/src/github.com/hashicorp/terraform 33 | cd /go/src/github.com/hashicorp/terraform && make 34 | ''' 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /images/cloud-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/images/cloud-configuration.png -------------------------------------------------------------------------------- /images/garbage-collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/images/garbage-collection.png -------------------------------------------------------------------------------- /images/mypod-1-general.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/images/mypod-1-general.png -------------------------------------------------------------------------------- /images/mypod-2-golang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/images/mypod-2-golang.png -------------------------------------------------------------------------------- /images/mypod-3-maven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/images/mypod-3-maven.png -------------------------------------------------------------------------------- /images/pod-template-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/images/pod-template-configuration.png -------------------------------------------------------------------------------- /kind-preload.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euxo pipefail 3 | cd $(dirname $0) 4 | 5 | PRE_LOAD_IMAGES=() 6 | PRE_LOAD_IMAGES+=(omrieival/ktunnel:v1.6.1) 7 | PRE_LOAD_IMAGES+=($(grep -h --include="*.groovy" -e "^\s*image: .*$" -R src/test/resources | sed -e "s/^[[:space:]]*image: //" | sort | uniq | grep -v "windows" | grep -v "nonexistent" | grep -v "invalid" | xargs)) 8 | PRE_LOAD_IMAGES+=($(grep -e FROM src/main/resources/org/csanchez/jenkins/plugins/kubernetes/Dockerfile | cut -d ' ' -f 2-)) 9 | if [[ -v cluster ]] 10 | then 11 | name_arg="--name $cluster" 12 | else 13 | name_arg= 14 | fi 15 | for image in "${PRE_LOAD_IMAGES[@]}" 16 | do 17 | docker pull "$image" 18 | kind load docker-image "$image" $name_arg 19 | done 20 | -------------------------------------------------------------------------------- /src/main/docker/master-executors.groovy: -------------------------------------------------------------------------------- 1 | import hudson.model.*; 2 | import jenkins.model.*; 3 | 4 | println "--> disabling controller executors" 5 | Jenkins.instance.setNumExecutors(0) 6 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/OpenShiftBearerTokenCredentialImpl.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes; 2 | 3 | import com.cloudbees.plugins.credentials.CredentialsScope; 4 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 5 | import hudson.model.Descriptor; 6 | import org.kohsuke.stapler.DataBoundConstructor; 7 | 8 | /** 9 | * @author Nicolas De Loof 10 | */ 11 | @Deprecated 12 | @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") 13 | public class OpenShiftBearerTokenCredentialImpl 14 | extends org.jenkinsci.plugins.kubernetes.credentials.OpenShiftBearerTokenCredentialImpl { 15 | 16 | private static final long serialVersionUID = -3725963485838773012L; 17 | 18 | @DataBoundConstructor 19 | public OpenShiftBearerTokenCredentialImpl( 20 | CredentialsScope scope, String id, String description, String username, String password) 21 | throws Descriptor.FormException { 22 | super(scope, id, description, username, password); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateLabelFilter.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes; 2 | 3 | import edu.umd.cs.findbugs.annotations.CheckForNull; 4 | import edu.umd.cs.findbugs.annotations.NonNull; 5 | import hudson.Extension; 6 | import hudson.model.Label; 7 | import hudson.model.Node; 8 | 9 | /** 10 | * Implementation of {@link PodTemplateFilter} filtering pod templates matching the right label. 11 | */ 12 | @Extension(ordinal = 1000) 13 | public class PodTemplateLabelFilter extends PodTemplateFilter { 14 | @Override 15 | protected PodTemplate transform( 16 | @NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate, @CheckForNull Label label) { 17 | if ((label == null && podTemplate.getNodeUsageMode() == Node.Mode.NORMAL) 18 | || (label != null && label.matches(podTemplate.getLabelSet()))) { 19 | return podTemplate; 20 | } 21 | return null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateSource.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes; 2 | 3 | import static java.util.stream.Collectors.toList; 4 | 5 | import edu.umd.cs.findbugs.annotations.NonNull; 6 | import hudson.ExtensionList; 7 | import hudson.ExtensionPoint; 8 | import java.util.Collection; 9 | import java.util.List; 10 | 11 | /** 12 | * A source of pod templates. 13 | */ 14 | public abstract class PodTemplateSource implements ExtensionPoint { 15 | public static List getAll(@NonNull KubernetesCloud cloud) { 16 | return ExtensionList.lookup(PodTemplateSource.class).stream() 17 | .map(s -> s.getList(cloud)) 18 | .flatMap(Collection::stream) 19 | .collect(toList()); 20 | } 21 | 22 | /** 23 | * The list of {@link PodTemplate} contributed by this implementation. 24 | * @return The list of {@link PodTemplate} contributed by this implementation. 25 | * @param cloud 26 | */ 27 | @NonNull 28 | protected abstract List getList(@NonNull KubernetesCloud cloud); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/ServiceAccountCredential.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes; 2 | 3 | import com.cloudbees.plugins.credentials.CredentialsScope; 4 | import org.jenkinsci.plugins.kubernetes.credentials.FileSystemServiceAccountCredential; 5 | import org.kohsuke.stapler.DataBoundConstructor; 6 | 7 | /** 8 | * Read the OAuth bearer token from service account file provisioned by kubernetes 9 | * Service Account Admission Controller 10 | * when Jenkins itself is deployed inside a Pod. 11 | * 12 | * @author Nicolas De Loof 13 | */ 14 | @Deprecated 15 | public class ServiceAccountCredential extends FileSystemServiceAccountCredential { 16 | 17 | private static final long serialVersionUID = 2739355565227800401L; 18 | 19 | @DataBoundConstructor 20 | public ServiceAccountCredential(CredentialsScope scope, String id, String description) { 21 | super(scope, id, description); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/TokenProducer.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes; 2 | 3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 4 | 5 | /** 6 | * @author Nicolas De Loof 7 | */ 8 | @Deprecated 9 | @SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_INTERFACE") 10 | public interface TokenProducer extends org.jenkinsci.plugins.kubernetes.credentials.TokenProducer {} 11 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/Constants.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline; 2 | 3 | /** 4 | * Created by iocanel on 7/29/16. 5 | */ 6 | public class Constants { 7 | 8 | public static final String EXIT = "exit"; 9 | public static final String NEWLINE = "\n"; // seems to work even on Windows 10 | public static final char CTRL_C = '\u0003'; 11 | public static final String SPACE = " "; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateContext.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Context object for PodTemplate during pipeline execution 7 | */ 8 | public class PodTemplateContext implements Serializable { 9 | private static final long serialVersionUID = 3065143885759619305L; 10 | 11 | private final String namespace; 12 | private final String name; 13 | 14 | public PodTemplateContext(String namespace, String name) { 15 | this.namespace = namespace; 16 | this.name = name; 17 | } 18 | 19 | public String getNamespace() { 20 | return namespace; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultNodeSelector.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; 2 | 3 | import edu.umd.cs.findbugs.annotations.NonNull; 4 | import hudson.Extension; 5 | import io.fabric8.kubernetes.api.model.Pod; 6 | import java.util.Collections; 7 | import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; 8 | 9 | /** 10 | * Sets the default node selector to linux if it hasn't been set explicitly in the pod before. 11 | */ 12 | @Extension 13 | public class DefaultNodeSelector implements PodDecorator { 14 | @NonNull 15 | @Override 16 | public Pod decorate(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod) { 17 | // default OS: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ 18 | if (pod.getSpec().getRuntimeClassName() == null 19 | && (pod.getSpec().getNodeSelector() == null 20 | || pod.getSpec().getNodeSelector().isEmpty()) 21 | && (pod.getSpec().getAffinity() == null 22 | || pod.getSpec().getAffinity().getNodeAffinity() == null)) { 23 | pod.getSpec().setNodeSelector(Collections.singletonMap("kubernetes.io/os", "linux")); 24 | } 25 | return pod; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultRestartPolicy.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; 2 | 3 | import edu.umd.cs.findbugs.annotations.NonNull; 4 | import hudson.Extension; 5 | import io.fabric8.kubernetes.api.model.Pod; 6 | import org.apache.commons.lang.StringUtils; 7 | import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; 8 | 9 | /** 10 | * Sets the restart policy to Never. 11 | */ 12 | @Extension 13 | public class DefaultRestartPolicy implements PodDecorator { 14 | @NonNull 15 | @Override 16 | public Pod decorate(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod) { 17 | if (StringUtils.isBlank(pod.getSpec().getRestartPolicy())) { 18 | pod.getSpec().setRestartPolicy("Never"); 19 | } 20 | return pod; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecoratorException.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; 2 | 3 | /** 4 | * A fatal exception raised by a {@link PodDecorator} implementation. 5 | */ 6 | public class PodDecoratorException extends RuntimeException { 7 | public PodDecoratorException(String message) { 8 | super(message); 9 | } 10 | 11 | public PodDecoratorException(String message, Throwable cause) { 12 | super(message, cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/PodOfflineCause.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pod.retention; 2 | 3 | import hudson.slaves.OfflineCause; 4 | import org.jvnet.localizer.Localizable; 5 | 6 | /** 7 | * {@link OfflineCause} for Kubernetes Pods. 8 | */ 9 | public class PodOfflineCause extends OfflineCause.SimpleOfflineCause { 10 | 11 | /** 12 | * Create new pod offline cause. 13 | * @param description offline description 14 | */ 15 | protected PodOfflineCause(Localizable description) { 16 | super(description); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/PodRetentionDescriptor.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pod.retention; 2 | 3 | import hudson.model.Descriptor; 4 | 5 | /** 6 | * A {@link Descriptor} for any {@link PodRetention} implementation. 7 | */ 8 | public abstract class PodRetentionDescriptor extends Descriptor {} 9 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Overrides.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pod.yaml; 2 | 3 | import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.parseFromYaml; 4 | 5 | import edu.umd.cs.findbugs.annotations.NonNull; 6 | import hudson.Extension; 7 | import hudson.model.Descriptor; 8 | import io.fabric8.kubernetes.api.model.Pod; 9 | import java.util.List; 10 | import org.jenkinsci.Symbol; 11 | import org.kohsuke.stapler.DataBoundConstructor; 12 | 13 | public class Overrides extends YamlMergeStrategy { 14 | private static final long serialVersionUID = 4510341864619338164L; 15 | 16 | @DataBoundConstructor 17 | public Overrides() {} 18 | 19 | @Override 20 | public Pod merge(List yamls) { 21 | if (yamls.isEmpty()) { 22 | return null; 23 | } else { 24 | return parseFromYaml(yamls.get(yamls.size() - 1)); 25 | } 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Override"; 31 | } 32 | 33 | @Extension 34 | @Symbol("override") 35 | public static class DescriptorImpl extends Descriptor { 36 | @NonNull 37 | @Override 38 | public String getDisplayName() { 39 | return "Override"; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/YamlMergeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pod.yaml; 2 | 3 | import edu.umd.cs.findbugs.annotations.NonNull; 4 | import hudson.ExtensionPoint; 5 | import hudson.model.AbstractDescribableImpl; 6 | import io.fabric8.kubernetes.api.model.Pod; 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | public abstract class YamlMergeStrategy extends AbstractDescribableImpl 11 | implements ExtensionPoint, Serializable { 12 | @NonNull 13 | public static YamlMergeStrategy defaultStrategy() { 14 | return new Overrides(); 15 | } 16 | 17 | public abstract Pod merge(@NonNull List yamls); 18 | 19 | @Override 20 | public String toString() { 21 | return getClass().getSimpleName(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/EphemeralVolume.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.volumes; 2 | 3 | import io.fabric8.kubernetes.api.model.Volume; 4 | import io.fabric8.kubernetes.api.model.VolumeBuilder; 5 | 6 | /** 7 | * Interface containing common code between {@link GenericEphemeralVolume} and {@link org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.GenericEphemeralWorkspaceVolume}. 8 | */ 9 | public interface EphemeralVolume extends ProvisionedVolume { 10 | default Volume buildEphemeralVolume(String volumeName) { 11 | return new VolumeBuilder() 12 | .withName(volumeName) 13 | .withNewEphemeral() 14 | .withNewVolumeClaimTemplate() 15 | .withNewSpec() 16 | .withAccessModes(getAccessModesOrDefault()) 17 | .withStorageClassName(getStorageClassNameOrDefault()) 18 | .withNewResources() 19 | .withRequests(getResourceMap()) 20 | .endResources() 21 | .endSpec() 22 | .endVolumeClaimTemplate() 23 | .endEphemeral() 24 | .build(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/PVCVolumeUtils.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.volumes; 2 | 3 | import hudson.util.ListBoxModel; 4 | 5 | public class PVCVolumeUtils { 6 | public static final ListBoxModel ACCESS_MODES_BOX = 7 | new ListBoxModel().add("ReadWriteOnce").add("ReadOnlyMany").add("ReadWriteMany"); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/ProvisionedVolume.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.volumes; 2 | 3 | import io.fabric8.kubernetes.api.model.Quantity; 4 | import java.util.Collections; 5 | import java.util.Map; 6 | import org.apache.commons.lang.StringUtils; 7 | 8 | public interface ProvisionedVolume { 9 | default String getStorageClassNameOrDefault() { 10 | return getStorageClassName(); 11 | } 12 | 13 | String getStorageClassName(); 14 | 15 | default Map getResourceMap() { 16 | return Collections.singletonMap("storage", new Quantity(getRequestsSizeOrDefault())); 17 | } 18 | 19 | default String getRequestsSizeOrDefault() { 20 | return StringUtils.defaultString(getRequestsSize(), "10Gi"); 21 | } 22 | 23 | String getRequestsSize(); 24 | 25 | default String getAccessModesOrDefault() { 26 | return StringUtils.defaultString(getAccessModes(), "ReadWriteOnce"); 27 | } 28 | 29 | String getAccessModes(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kubernetes/service-account.yml: -------------------------------------------------------------------------------- 1 | # In GKE need to get RBAC permissions first with 2 | # kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin [--user=|--group=] 3 | 4 | --- 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | name: jenkins 9 | 10 | --- 11 | kind: Role 12 | apiVersion: rbac.authorization.k8s.io/v1 13 | metadata: 14 | name: jenkins 15 | rules: 16 | - apiGroups: [""] 17 | resources: ["pods"] 18 | verbs: ["create","delete","get","list","patch","update","watch"] 19 | - apiGroups: [""] 20 | resources: ["pods/exec"] 21 | verbs: ["create","delete","get","list","patch","update","watch"] 22 | - apiGroups: [""] 23 | resources: ["pods/log"] 24 | verbs: ["get","list","watch"] 25 | - apiGroups: [""] 26 | resources: ["events"] 27 | verbs: ["watch"] 28 | - apiGroups: [""] 29 | resources: ["secrets"] 30 | verbs: ["get"] 31 | 32 | --- 33 | apiVersion: rbac.authorization.k8s.io/v1 34 | kind: RoleBinding 35 | metadata: 36 | name: jenkins 37 | roleRef: 38 | apiGroup: rbac.authorization.k8s.io 39 | kind: Role 40 | name: jenkins 41 | subjects: 42 | - kind: ServiceAccount 43 | name: jenkins 44 | -------------------------------------------------------------------------------- /src/main/resources/index.jelly: -------------------------------------------------------------------------------- 1 | 2 |
3 | This plugin integrates Jenkins with 4 | Kubernetes 5 |
6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe/config.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe/help-execArgs.html: -------------------------------------------------------------------------------- 1 | Command executed by the liveness probe. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe/help-failureThreshold.html: -------------------------------------------------------------------------------- 1 |

2 | When a Pod starts and the probe fails, Kubernetes will try failureThreshold times before giving up.
3 | Giving up in case of liveness probe means restarting the container.
4 | In case of readiness probe the Pod will be marked Unready. Defaults to 3. Minimum value is 1. 5 |

6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe/help-initialDelaySeconds.html: -------------------------------------------------------------------------------- 1 | Number of seconds after the container has started before liveness or readiness probes are initiated. Defaults to 0 seconds. Minimum value is 0. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe/help-periodSeconds.html: -------------------------------------------------------------------------------- 1 |

2 | How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. 3 |

4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe/help-successThreshold.html: -------------------------------------------------------------------------------- 1 | Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness. Minimum value is 1. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe/help-timeoutSeconds.html: -------------------------------------------------------------------------------- 1 | Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-alwaysPullImage.html: -------------------------------------------------------------------------------- 1 | If ticked, the latest version of the image will be pulled every time it is used. 2 | 3 | See Images - Kubernetes for the default Kubernetes behaviour. 4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-args.html: -------------------------------------------------------------------------------- 1 |

Arguments to pass to the command.

2 |

${computer.jnlpmac} and ${computer.name} are replaced with the agent secret and name respectively.

3 |

For Windows containers the args Start-Sleep 999999 are reasonable choices to go with powershell.

4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-command.html: -------------------------------------------------------------------------------- 1 |

Override the image entrypoint with a different one.

2 |

For Windows containers powershell is a good default.

3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-envVars.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | The environment variables to pass to the container. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-image.html: -------------------------------------------------------------------------------- 1 | Container image (repository, name, and tag) for a Jenkins inbound agent. 2 | Connection details will be passed as environment variables as per 3 | documentation. 4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-name.html: -------------------------------------------------------------------------------- 1 | The name for the container to be run. 2 | 3 | One container is automatically created with the name jnlp, and runs the Jenkins agent. 4 | 5 | In order to replace the default agent image, the container with the agent must be named jnlp. 6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-privileged.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | Flag to mark the container as privileged. 18 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-resourceLimitCpu.html: -------------------------------------------------------------------------------- 1 | Kubernetes Resources Limit of CPU 2 | This value can be set to control the CPU resource limit passed when creating the Jenkins agent Docker container in 3 | Kubernetes. Unlike a resource request, this is the upper limit of resources used by your Jenkins Agent container. 4 | When left blank, the defaults of your Kubernetes cluster will be used. For more info, see the 5 | Kubernetes docs. 6 | e.g. `500m`. 7 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-resourceLimitMemory.html: -------------------------------------------------------------------------------- 1 | Kubernetes Resources Limit of Memory 2 | This value can be set to control the memory resource limit passed when creating the Jenkins agent Docker container in 3 | Kubernetes. Unlike a resource request, this is the upper limit of resources used by your Jenkins Agent container. 4 | When left blank, the defaults of your Kubernetes cluster will be used. For more info, see the 5 | Kubernetes docs. 6 | e.g. `250Mi`. 7 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-resourceRequestCpu.html: -------------------------------------------------------------------------------- 1 | Kubernetes Resources Request of CPU 2 | This value can be set to control the CPU resources requested when creating the Jenkins agent Docker container in 3 | Kubernetes. When left blank, the defaults of your Kubernetes cluster will be used. For more info, see the 4 | Kubernetes docs. 5 | e.g. `500m`. 6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-resourceRequestMemory.html: -------------------------------------------------------------------------------- 1 | Kubernetes Resources Request of Memory 2 | This value can be set to control the memory resources requested when creating the Jenkins agent Docker container in 3 | Kubernetes. When left blank, the defaults of your Kubernetes cluster will be used. For more info, see the 4 | Kubernetes docs. 5 | e.g. `250Mi`. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-runAsGroup.html: -------------------------------------------------------------------------------- 1 | Specify the gid to run as. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-runAsUser.html: -------------------------------------------------------------------------------- 1 | Specify the uid to run as. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-ttyEnabled.html: -------------------------------------------------------------------------------- 1 | Whether this container should allocate a TTY for itself. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ContainerTemplate/help-workingDir.html: -------------------------------------------------------------------------------- 1 | Path to the root of the workspace from the view point of this container, such as /home/jenkins/agent. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jenkins/inbound-agent:3309.v27b_9314fd1a_4-1 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/GarbageCollection/help-namespaces.html: -------------------------------------------------------------------------------- 1 | Namespaces to look at for garbage collection, in addition to the default namespace defined for the cloud. 2 | One namespace per line. 3 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper/help-caCertificate.html: -------------------------------------------------------------------------------- 1 |
2 | The base64 encoded certificate of the certificate authority (CA). It is used to verify the server certificate. 3 |

Leaving this field empty will skip the certificate verification.

4 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper/help-serverUrl.html: -------------------------------------------------------------------------------- 1 |
2 | URL of the Kubernetes API endpoint. If not set the connection options will be autoconfigured from service account or kube config file. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper/help.html: -------------------------------------------------------------------------------- 1 |
2 | Configure Kubernetes client (kubectl) so it can be used in the build to run Kubernetes commands 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-addMasterProxyEnvVars.html: -------------------------------------------------------------------------------- 1 | With this option enabled, if any of the HTTP proxy related environment variables 2 | recognized by the Jenkins remoting component are set on the Jenkins Controller, they 3 | will be added to the environment variables of any Pod Template. 4 |

5 | Any explicit setting of those variables in the environment variables section of 6 | the Pod Template or Container Template will take precedence over any variables 7 | set in Jenkins Controller. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-connectTimeout.html: -------------------------------------------------------------------------------- 1 |

2 | The connection timeout in seconds for connections to Kubernetes API. Minimum value is 5. 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-containerCapStr.html: -------------------------------------------------------------------------------- 1 |
2 | The maximum number of concurrently running agent pods that are permitted in this Kubernetes Cloud. 3 | If set to empty it means no limit. 4 |
5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-defaultsProviderTemplate.html: -------------------------------------------------------------------------------- 1 |
2 | The name of the pod template to use for providing default values. 3 | When a value is specified and there is a pod template with a matching name, the template will be 4 | used as a parent to all other pod templates. 5 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-directConnection.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | With this option it is possible to connect directly to the TCP agent listener port. 4 | This skips the connection to an HTTP(S) port to retrieve some metadata. 5 |

6 | 7 |

8 | This is useful in scenarios where the controller does not expose an HTTP(S) port, for example 9 | Jenkinsfile Runner, 10 | but more commonly if you simply wish to optimize the connection slightly. 11 |

12 | 13 |

14 | Note: In Direct Connection mode agents will not be able to reconnect to a restarted controller if a Random 'TCP port for inbound agents' is configured!
15 | Note: Direct Connection does not work with the currently available jenkins/inbound-agent:windowsservercore-1809 image. 16 |

17 | 18 |
19 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-garbageCollection.html: -------------------------------------------------------------------------------- 1 |

2 | Enables garbage collection of orphan pods for this Kubernetes cloud.
3 | 4 | When enabled, Jenkins will periodically check for orphan pods that have not been touched for the given timeout period and delete them. 5 |

6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-jenkinsTunnel.html: -------------------------------------------------------------------------------- 1 |
2 | Connect to the specified host and port, instead of connecting directly to Jenkins. 3 | Useful when connection to Jenkins needs to be tunneled. Can be also HOST: or :PORT, 4 | in which case the missing portion will be auto-configured like the default behavior 5 |
6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-jenkinsUrl.html: -------------------------------------------------------------------------------- 1 |
2 | The URL of the Jenkins Controller server. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-jnlpregistry.html: -------------------------------------------------------------------------------- 1 |
2 | Provide the Docker registry you want to use to pull the agent image if none is specified 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-maxRequestsPerHostStr.html: -------------------------------------------------------------------------------- 1 |
2 | The maximum number of concurrent requests to the Kubernetes API. If you set this too low, you might run into JENKINS-40825. 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-name.html: -------------------------------------------------------------------------------- 1 |
2 | Uniquely identifies this Cloud instance among other instances in Jenkins Clouds. 3 | This is expected to be short ID-like string that does not contain any character unsafe as variable name or 4 | URL path token. 5 |
6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-password.html: -------------------------------------------------------------------------------- 1 |
2 | The password of the authorized user on the Kubernetes API server. Can be blank for unsecured access. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-podLabels.html: -------------------------------------------------------------------------------- 1 |
2 | Labels 3 | for all Pods started by the plugin. Pods that match these labels count toward the Concurrency Limit. 4 |

5 | If not configured, all Pods will be created with jenkins=slave by default. 6 |

7 |

Examples: 8 |

    9 |
  • jenkins=slave
  • 10 |
  • app.kubernetes.io/managed-by=jenkins
  • 11 |
  • app.kubernetes.io/part-of=cicd
  • 12 |
13 |

14 |
15 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-podRetention.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | This setting controls how agent pods are retained after the Jenkins build completes. 4 | The following retention policies are provided: 5 |

6 |
    7 |
  1. Never - always delete the agent pod.
  2. 8 |
  3. On Failure - keep the agent pod if it fails during the build.
  4. 9 |
  5. Always - always keep the agent pod.
  6. 10 |
11 |

12 | Note: Kubernetes administrators are responsible for managing any kept agent pod. 13 | These will not be deleted by the Jenkins Kubernetes plugin. 14 |

15 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-readTimeout.html: -------------------------------------------------------------------------------- 1 |
2 | The read timeout in seconds for connections to Kubernetes API. Minimum value is 15. 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-restrictedPssSecurityContext.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | When using Pod Security Admission in the Agents namespace 4 | with the restricted Pod Security Standard, the 5 | jnlp container cannot be scheduled without overriding its container definition with a securityContext. 6 |

7 |

8 | This option allows to automatically inject in the jnlp container a securityContext that is suitable for the use 9 | of the restricted Pod Security Standard. 10 |

11 |

12 | This is the securityContext that will be used for the jnlp container with that option: 13 |

14 |
securityContext:
15 |   allowPrivilegeEscalation: false
16 |   capabilities:
17 |     drop:
18 |     - ALL
19 |   runAsNonRoot: true
20 |   seccompProfile:
21 |     type: RuntimeDefault
22 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-retentionTimeout.html: -------------------------------------------------------------------------------- 1 |

2 | Time in minutes after which the Kubernetes cloud plugin will clean up an idle 3 | worker that has not already terminated. This cleanup is only necessary in 4 | exceptional conditions; typically workers will terminate upon completion of the 5 | invoking task. 6 |

7 | 8 |

9 | Minimum value is 5 minutes as lower values can cause problems upon Jenkins restart. 10 |

11 | 12 |

13 | For tasks that use very large images, this timeout can be increased to avoid 14 | early termination of the task while the Kubernetes pod is still deploying. 15 |

16 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-serverCertificate.html: -------------------------------------------------------------------------------- 1 |
2 | X509 PEM encoded certificate. Can be additionally base64 encoded (as provided by Amazon EKS). 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-serverUrl.html: -------------------------------------------------------------------------------- 1 |
2 | The URL of the Kubernetes API server. If not set the connection options will be autoconfigured from service account or kube config file. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-skipTlsVerify.html: -------------------------------------------------------------------------------- 1 | With this option enabled, communication with kubernetes API server will rely on https but will fully ignore ssl 2 | certificate verification. This is usefull for quick setup but does make your installation unsecured, so please consider 3 | twice. 4 |

5 | Alternatively, capture API server certificate and register it as Kubernetes server certificate key. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-usageRestricted.html: -------------------------------------------------------------------------------- 1 |

2 | When using this option, you need to grant explicitly access to this cloud using the podTemplate pipeline keyword. 3 | The permission can be granted by selecting this cloud in the Kubernetes Section of the folder configuration. 4 | All Pipeline Jobs in the folder and its children will then be granted permission to use this cloud. 5 |
6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-useJenkinsProxy.html: -------------------------------------------------------------------------------- 1 |
2 | use Jenkins proxy settings to connect to kubernetes URL 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-username.html: -------------------------------------------------------------------------------- 1 |
2 | The user name of an authorized user on the Kubernetes API server. Can be blank for unsecured access. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-waitForPodSec.html: -------------------------------------------------------------------------------- 1 |
2 | How long to wait (seconds) for pod to be in running state. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/help-webSocket.html: -------------------------------------------------------------------------------- 1 |
2 | Use WebSocket to connect agents rather than the TCP port. 3 | See JEP-222 for background. 4 |
5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud/sidepanel.properties: -------------------------------------------------------------------------------- 1 | delete.cloud=Delete the cloud ''{0}'' ? 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ${%Allow pipeline support for the following restricted Kubernetes Clouds} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave/configure-entries.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/NonConfigurableKubernetesCloud/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | Cloud name: ${instance.displayName} 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodAnnotation/config.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodAnnotation/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | Key=\u952E 24 | Value=\u503C 25 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodAnnotation/help-key.html: -------------------------------------------------------------------------------- 1 | The annotation key. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodAnnotation/help-value.html: -------------------------------------------------------------------------------- 1 | The annotation value. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodImagePullSecret/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodImagePullSecret/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | Name=\u540D\u79F0 24 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodImagePullSecret/help-name.html: -------------------------------------------------------------------------------- 1 | The image pull secret name -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodLabel/config.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodLabel/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | Key=\u952E 24 | Value=\u503C 25 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodLabel/help-key.html: -------------------------------------------------------------------------------- 1 | Valid label keys have two segments: an optional prefix and name, separated by a slash (/). The name 2 | segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character 3 | ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and 4 | alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS 5 | labels separated by dots (.), not longer than 253 characters in total, followed by a slash (/). 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodLabel/help-value.html: -------------------------------------------------------------------------------- 1 | Valid label values must be 63 characters or less and must be empty or begin and end with an alphanumeric character 2 | ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), 3 | and alphanumerics between. 4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-activeDeadlineSeconds.html: -------------------------------------------------------------------------------- 1 | Specify time in seconds time after which Kubernetes will kill the pod if it has not completed. 2 | Value should be a positive integer, default being empty which means no activeDeadlineSeconds will be specified. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-agentContainer.html: -------------------------------------------------------------------------------- 1 |

The name of the container running the Jenkins agent in the pod.

2 | 3 |

This container will receive environment variables required to connect to the Jenkins controller.

4 | 5 |

Defaults to jnlp.

6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-agentInjection.html: -------------------------------------------------------------------------------- 1 |

This option lets you provide a container image that does not extend the Jenkins agent image.

2 | 3 |

The provided container image must have a (headless) JRE installed (using a version compatible with the current Jenkins version).

4 | 5 |

The agent will use the Java installation designated by the JENKINS_JAVA_BIN environment variable, or the one in PATH if undefined.

6 | 7 |

Enabling this option will override the command and arguments defined in the agent container.

8 | 9 |

Example

10 | 11 |
12 | podTemplate(agentContainer:'foo',
13 |             agentInjection: true,
14 |             yaml:'''
15 | spec:
16 |   containers:
17 |   - name: foo
18 |     image: eclipse-temurin:22.0.2_9-jre
19 | ''') {
20 |   node(POD_LABEL) {
21 |     sh 'true'
22 |   }
23 | }
24 | 
25 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-annotations.html: -------------------------------------------------------------------------------- 1 |

2 | Annotations to set on pod metadata
3 | Read Annotations - Kubernetes for more information. 4 |

5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-containers.html: -------------------------------------------------------------------------------- 1 | By default, the pod contains a single container with name jnlp running the Jenkins agent.
2 | It is possible to override this container by adding a new entry and use jnlp as name. 3 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-envVars.html: -------------------------------------------------------------------------------- 1 | Environment variables can be hardcoded, or injected from a Kubernetes secret. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-hostNetwork.html: -------------------------------------------------------------------------------- 1 | Allows the pod to share the host network namespace. Not recommended. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-idleMinutes.html: -------------------------------------------------------------------------------- 1 |

2 | By default, agents are terminated as soon as they have completed the task they have been assigned. 3 |

4 | 5 |

6 | Setting a value for this field will keep agents around for N minutes (N being the defined value).
7 | In that case, the agent may be reused by another build. 8 |

9 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-imagePullSecrets.html: -------------------------------------------------------------------------------- 1 | 16 | Name of secrets that can be used to pull the specified image. 17 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-inheritFrom.html: -------------------------------------------------------------------------------- 1 |

2 | Name of the podTemplate to inherit from. 3 |

4 |

5 | A podTemplate may or may not inherit from an existing template.
6 | This means that the podTemplate will inherit node selector, service account, image pull secrets, containerTemplates and volumes from the template it inherits from. 7 |

8 |

9 | Service account and Node selector, when overridden, completely replace any value found on the “parent”. 10 |

11 |

12 | Container templates that are added to the podTemplate, that has a matching containerTemplate (a containerTemplate with the same name) in the parent template, will inherit the configuration of the parent containerTemplate.
13 | If no matching containerTemplate is found, the template is added as is. 14 |

15 | Volume inheritance works exactly as Container templates. 16 |

17 | Image Pull Secrets are combined (all secrets defined both on 'parent' and 'current' template are used). 18 |

19 |

20 | By default, pod template inherits outer pod template definitions.
21 | Inheritance can be stopped by using the empty string. 22 |

23 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-inheritYamlMergeStrategy.html: -------------------------------------------------------------------------------- 1 | Controls whether the defined yaml merge strategy will be inherited if another defined pod template is configured to inherit from the current one. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-instanceCap.html: -------------------------------------------------------------------------------- 1 |

2 | The maximum number of concurrently running agent pods created from this template that are permitted in the Kubernetes Cloud.
3 | The number of running agents will never exceed the global concurrency limit sets at the Cloud Configuration level.
4 | If set to empty or a negative number it means no limit. 5 |

6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-label.html: -------------------------------------------------------------------------------- 1 | Labels to put on the created agents 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-name.html: -------------------------------------------------------------------------------- 1 | 16 |

17 | Name that identifies the pod template. Also used to prefix the name of the node and pod created. 18 |

19 |

20 | When omitted, the agent and pod name is randomly generated using jenkins-agent- as a prefix. 21 | When omitted in a podTemplate(...) step, the label is used as a prefix for the name of the dynamic pod template. 22 |

-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-namespace.html: -------------------------------------------------------------------------------- 1 | Namespace in which to schedule the pod.
2 | 3 | Leave empty to use the namespace defined at cloud level. 4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-nodeSelector.html: -------------------------------------------------------------------------------- 1 | Specify which nodes the pod should operate on by providing a comma separated list of node labels: 2 | `label1=value1,label2=value2`. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-podRetention.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | This setting controls how agent pods are retained after the Jenkins build completes for this pod template. 4 | Values other than "Default" will override the plugin's Pod Retention setting. 5 | The following retention policies are provided: 6 |

7 |
    8 |
  1. Always - always keep the agent pod.
  2. 9 |
  3. Default - use the Pod Retention setting for the plugin.
  4. 10 |
  5. Never - always delete the agent pod.
  6. 11 |
  7. On Failure - keep the agent pod if it fails during the build.
  8. 12 |
13 |

14 | Note: Kubernetes administrators are responsible for managing any kept agent pod. 15 | These will not be deleted by the Jenkins Kubernetes plugin. 16 |

17 |
18 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-runAsGroup.html: -------------------------------------------------------------------------------- 1 | Specify the gid to run as. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-runAsUser.html: -------------------------------------------------------------------------------- 1 | Specify the uid to run as. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-serviceAccount.html: -------------------------------------------------------------------------------- 1 | The service account to use to run the pod. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-showRawYaml.html: -------------------------------------------------------------------------------- 1 |

2 | When checked, the actual pod definition in YAML will be dumped in the build console (secrets redacted).
3 | This helps audit builds to understand what was the exact environment when the build ran.
4 | If you don't care about this information and want less verbosity in build logs, disable this feature. 5 |

6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-slaveConnectTimeout.html: -------------------------------------------------------------------------------- 1 |

2 | Specify time in seconds up to which Jenkins should wait for the agent to establish a connection.
3 | Value must be a positive integer. 4 |

5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-supplementalGroups.html: -------------------------------------------------------------------------------- 1 | A comma-separated list of GIDs to add in the containers. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-volumes.html: -------------------------------------------------------------------------------- 1 |

2 | Volumes get mounted in all containers with the specified mount path.
3 | If you want more fine-grained control, use the raw YAML field. 4 |

5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-workingDir.html: -------------------------------------------------------------------------------- 1 | Path to the root of the workspace from the view point of this node, such as /home/jenkins/agent. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-workspaceVolume.html: -------------------------------------------------------------------------------- 1 | Specifies the type of volume to be used to mount the agent workspace. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/help-yamlMergeStrategy.html: -------------------------------------------------------------------------------- 1 | Defines how the raw yaml field gets merged with yaml definitions from inherited pod templates. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplate/sidepanel.properties: -------------------------------------------------------------------------------- 1 | delete.template=Delete the pod template ''{0}''? 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PortMapping/config.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PortMapping/help-containerPort.html: -------------------------------------------------------------------------------- 1 | Port to expose into the pod 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PortMapping/help-hostPort.html: -------------------------------------------------------------------------------- 1 | Port to expose onto the host 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/PortMapping/help-name.html: -------------------------------------------------------------------------------- 1 | The name of the port 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/ServiceAccountCredential/credentials.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/KeyValueEnvVar/config.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/KeyValueEnvVar/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | Key=\u952E 24 | Value=\u503C 25 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/KeyValueEnvVar/help-key.html: -------------------------------------------------------------------------------- 1 | The environment variable key. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/KeyValueEnvVar/help-value.html: -------------------------------------------------------------------------------- 1 | The environment variable value. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/SecretEnvVar/config.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/SecretEnvVar/help-key.html: -------------------------------------------------------------------------------- 1 | The environment variable key. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/SecretEnvVar/help-optional.html: -------------------------------------------------------------------------------- 1 | Whether this secret is optional. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/SecretEnvVar/help-secretKey.html: -------------------------------------------------------------------------------- 1 | Key of secret to lookup from Kubernetes. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/model/SecretEnvVar/help-secretName.html: -------------------------------------------------------------------------------- 1 | Name of secret to lookup from Kubernetes. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStep/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

7 | Gets the log of a container running in the current pod, and prints it to the build log or returns it. 8 | Only works inside a node that requests a Kubernetes agent. 9 |

10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStep/help-limitBytes.html: -------------------------------------------------------------------------------- 1 |
2 | If set, the number of bytes to read from the server before terminating the log output. This may not display a complete final line of logging, and may return slightly more or slightly less than the specified limit. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStep/help-name.html: -------------------------------------------------------------------------------- 1 |
2 | Name of the container, as specified in containerTemplate. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStep/help-returnLog.html: -------------------------------------------------------------------------------- 1 |
2 | Return the container log. If not checked, the log will be printed to the build log. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStep/help-sinceSeconds.html: -------------------------------------------------------------------------------- 1 |
2 | A relative time in seconds before the current time from which to show logs. If this value precedes the time a pod was started, only logs since the pod start will be returned. If this value is in the future, no logs will be returned. 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStep/help-tailingLines.html: -------------------------------------------------------------------------------- 1 |
2 | If set, the number of lines from the end of the log to show. If not specified, log is shown from the creation of the container or limited by "sinceSeconds". 3 |
-------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStep/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStep/help-shell.html: -------------------------------------------------------------------------------- 1 |

2 | Specifies a shell which will run inside the container 3 | and process requests from Jenkins to run executables, 4 | set environment variables, and similar infrastructure. 5 |

6 |

7 | This does not affect the shell used to run user code, 8 | such as sh steps. 9 | To run your scripts with a specific shell on Linux, use an interpreter line: 10 |

11 |
sh '''#!/bin/bash
12 | for x in {0..9}; do echo x; done
13 | '''
14 |

15 | or just use a subprocess and an externally versioned script: 16 |

17 |
sh 'bash ci.sh'
18 |

19 | On Windows, choose between the bat or powershell steps. 20 |

21 |

22 | For a pod running on Linux, defaults to sh, which should be in $PATH; 23 | for a pod running on Windows, defaults to cmd, which should be in %Path%. 24 | Should not generally be overridden. 25 |

26 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStep/help.html: -------------------------------------------------------------------------------- 1 |
2 | Selects a container of the agent pod so that all shell steps are executed in that container. 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition/help-handleNonKubernetes.html: -------------------------------------------------------------------------------- 1 |
2 | Behave like the generic agent() (Agent errors) when applied to a non-Kubernetes agent. 3 | Useful in cases where it is hard to predict in a job definition whether a Kubernetes or other sort of agent will be used. 4 |
5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition/help.html: -------------------------------------------------------------------------------- 1 |
2 | Similar to agent() (Agent errors) but tailored to agents provisioned from a Kubernetes cloud. 3 | Unlike the generic agent error condition, 4 | this will ignore certain pod termination reasons which are likely to be under the control of the Pipeline author (e.g., OOMKilled) 5 | while still allowing retry to recover after common cases of pod deletion. 6 |
7 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent/help-customWorkspace.html: -------------------------------------------------------------------------------- 1 | Allows the SCM repository to be checked out in a custom workspace directory. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent/help-defaultContainer.html: -------------------------------------------------------------------------------- 1 |

Name of the default container steps will be run in.

2 | 3 |

When using this option, all steps will be executed within an implicit container(name) {...} block instead 4 | of the jnlp container.

5 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/Messages.properties: -------------------------------------------------------------------------------- 1 | KubernetesDeclarativeAgent.displayName=Run inside a Kubernetes pod 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep/help-cloud.html: -------------------------------------------------------------------------------- 1 | The Kubernetes cloud to use to schedule the pod.
2 | If unset, the first available Kubernetes cloud will be used. 3 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep/help-label.html: -------------------------------------------------------------------------------- 1 |
2 | Jenkins node label to bind. 3 | If left blank, one will be generated for you, 4 | and inside the step it will be bound to the variable POD_LABEL 5 | so you can use this as the argument to the node step.
6 | 7 | Example: 8 |
 9 |         podTemplate(...) {
10 |             node(POD_LABEL) {
11 |                 // some steps
12 |             }
13 |         }
14 |     
15 |
16 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep/help.html: -------------------------------------------------------------------------------- 1 |

2 | Defines a Kubernetes pod template that can be used to create nodes. 3 |

4 |

5 | Example: 6 |

7 |
 8 | podTemplate(...) {
 9 |     node(POD_LABEL) {
10 |         // some steps
11 |     }
12 | }
13 | 
14 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/samples/windows.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Runs a build on a Windows pod. 3 | * Tested in EKS: https://docs.aws.amazon.com/eks/latest/userguide/windows-support.html 4 | */ 5 | podTemplate(yaml: ''' 6 | apiVersion: v1 7 | kind: Pod 8 | spec: 9 | containers: 10 | - name: jnlp 11 | image: jenkins/inbound-agent:windowsservercore-1809 12 | - name: shell 13 | image: mcr.microsoft.com/powershell:preview-windowsservercore-1809 14 | command: 15 | - powershell 16 | args: 17 | - Start-Sleep 18 | - 999999 19 | nodeSelector: 20 | kubernetes.io/os: windows 21 | ''') { 22 | retry(count: 2, conditions: [kubernetesAgent(), nonresumable()]) { 23 | node(POD_LABEL) { 24 | container('shell') { 25 | powershell 'Get-ChildItem Env: | Sort Name' 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Merge/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | The yaml definitions from inherited pod templates are merged with the current template yaml fragment. 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Overrides/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | The yaml definitions from inherited pod templates are completely overridden by the current yaml field. 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume/help-configMapName.html: -------------------------------------------------------------------------------- 1 | The name of the Kubernetes Config Map to mount into the pod. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume/help-optional.html: -------------------------------------------------------------------------------- 1 | Whether this configmap needs to exist. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/DynamicPVCVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | This feature is deprecated. Please use generic ephemeral volume instead, which provides the same functionality without requiring explicit RBAC permissions to create persistent volume claims. 6 |

7 | Allocates a PVC dynamically using the specified parameters, then deletes it when the pod is deleted. 8 | Note that this requires the Jenkins controller to have additional RBAC permissions than are typically needed for agent provisioning. 9 |

10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/EmptyDirVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/EmptyDirVolume/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | In\ Memory=\u5185\u5B58\u4E2D 24 | Mount\ path=\u6302\u8F7D\u8DEF\u5F84 -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/EmptyDirVolume/help-memory.html: -------------------------------------------------------------------------------- 1 | Flag for in-memory volume. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/GenericEphemeralVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | Creates a generic ephemeral volume using the specified parameters. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | Host\ path=\u4E3B\u673A\u8DEF\u5F84 24 | Mount\ path=\u6302\u8F7D\u8DEF\u5F84 -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume/help-hostPath.html: -------------------------------------------------------------------------------- 1 | File or directory on the host node's filesystem to mount into the pod. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume/help-readOnly.html: -------------------------------------------------------------------------------- 1 | Flag for read-only mount, set hostPath mount to readOnly is considered best-practice. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/NfsVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/NfsVolume/help-serverAddress.html: -------------------------------------------------------------------------------- 1 | NFS Server Address. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/NfsVolume/help-serverPath.html: -------------------------------------------------------------------------------- 1 | NFS Server Path. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim/help-claimName.html: -------------------------------------------------------------------------------- 1 | The claim name. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim/help-readOnly.html: -------------------------------------------------------------------------------- 1 | Flag for read-only volume. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PodVolume/help-accessModes.html: -------------------------------------------------------------------------------- 1 | A PersistentVolume can be mounted on a host in any way supported by the resource provider. 2 | Providers will have different capabilities and each PV’s access modes are set to the specific modes supported by that particular volume. 3 | For example, NFS can support multiple read/write clients, but a specific NFS PV might be exported on the server as read-only. 4 | Each PV gets its own set of access modes describing that specific PV’s capabilities. 5 | Defaults to ReadWriteOnce. 6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PodVolume/help-mountPath.html: -------------------------------------------------------------------------------- 1 | Path to mount this volume inside the pod. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PodVolume/help-requestsSize.html: -------------------------------------------------------------------------------- 1 | Claims, like pods, can request specific quantities of a resource. In this case, the request is for storage. The same resource model applies to both volumes and claims. Defaults to 10Gi. 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PodVolume/help-storageClassName.html: -------------------------------------------------------------------------------- 1 | A StorageClass provides a way for administrators to describe the “classes” of storage they offer. Different classes might map to quality-of-service levels, or to backup policies, or to arbitrary policies determined by the cluster administrators. Kubernetes itself is unopinionated about what classes represent. This concept is sometimes called “profiles” in other storage systems. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/PodVolume/help-subPath.html: -------------------------------------------------------------------------------- 1 | SubPath to mount this volume inside the pod. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | Secret\ name=Secret \u540D\u79F0 24 | Mount\ path=\u6302\u8F7D\u8DEF\u5F84 25 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume/help-defaultMode.html: -------------------------------------------------------------------------------- 1 | The file permissions for the secret volume. Does not support Octal notation. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume/help-optional.html: -------------------------------------------------------------------------------- 1 | Whether the secret needs to exist. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume/help-secretName.html: -------------------------------------------------------------------------------- 1 | The name of the Kubernetes Secret to mount into the pod. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/DynamicPVCWorkspaceVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | This feature is deprecated. Please use generic ephemeral volume instead, which provides the same functionality without requiring explicit RBAC permissions to create persistent volume claims. 6 |

7 | Allocates a PVC dynamically using the specified parameters, then deletes it when the pod is deleted. 8 | Note that this requires the Jenkins controller to have additional RBAC permissions than are typically needed for agent provisioning. 9 |

10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | In\ Memory=\u5185\u5B58\u4E2D 24 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume/help-memory.html: -------------------------------------------------------------------------------- 1 | Flag for in-memory volume. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume/help-sizeLimit.html: -------------------------------------------------------------------------------- 1 | Sets a size limit. If the workspace size exceeds the specified size, the pod will be evicted. See details. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/GenericEphemeralWorkspaceVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | Creates a generic ephemeral volume using the specified parameters. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/HostPathWorkspaceVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/HostPathWorkspaceVolume/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2018, Alauda 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | Host\ path=\u4E3B\u673A\u8DEF\u5F84 24 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/HostPathWorkspaceVolume/help-hostPath.html: -------------------------------------------------------------------------------- 1 | File or directory on the host node's filesystem to mount into the pod. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/NfsWorkspaceVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/NfsWorkspaceVolume/help-serverAddress.html: -------------------------------------------------------------------------------- 1 | NFS Server Address. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/NfsWorkspaceVolume/help-serverPath.html: -------------------------------------------------------------------------------- 1 | NFS Server Path. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/PersistentVolumeClaimWorkspaceVolume/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/PersistentVolumeClaimWorkspaceVolume/help-claimName.html: -------------------------------------------------------------------------------- 1 | The claim name. -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/PersistentVolumeClaimWorkspaceVolume/help-readOnly.html: -------------------------------------------------------------------------------- 1 | Flag for read-only volume. 2 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/WorkspaceVolume/help-accessModes.html: -------------------------------------------------------------------------------- 1 | A PersistentVolume can be mounted on a host in any way supported by the resource provider. 2 | Providers will have different capabilities and each PV’s access modes are set to the specific modes supported by that particular volume. 3 | For example, NFS can support multiple read/write clients, but a specific NFS PV might be exported on the server as read-only. 4 | Each PV gets its own set of access modes describing that specific PV’s capabilities. 5 | Defaults to ReadWriteOnce. 6 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/WorkspaceVolume/help-requestsSize.html: -------------------------------------------------------------------------------- 1 | Claims, like pods, can request specific quantities of a resource. In this case, the request is for storage. The same resource model applies to both volumes and claims. Defaults to 10Gi. 2 | 3 | -------------------------------------------------------------------------------- /src/main/resources/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/WorkspaceVolume/help-storageClassName.html: -------------------------------------------------------------------------------- 1 | A StorageClass provides a way for administrators to describe the “classes” of storage they offer. Different classes might map to quality-of-service levels, or to backup policies, or to arbitrary policies determined by the cluster administrators. Kubernetes itself is unopinionated about what classes represent. This concept is sometimes called “profiles” in other storage systems. 2 | -------------------------------------------------------------------------------- /src/main/webapp/images/24x24/kubernetes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/src/main/webapp/images/24x24/kubernetes.png -------------------------------------------------------------------------------- /src/main/webapp/images/32x32/kubernetes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/src/main/webapp/images/32x32/kubernetes.png -------------------------------------------------------------------------------- /src/main/webapp/images/48x48/kubernetes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/kubernetes-plugin/b47977da9417621031f32dcb97ff9e5f83366fcd/src/main/webapp/images/48x48/kubernetes.png -------------------------------------------------------------------------------- /src/spotbugs/excludesFilter.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/MetricNamesTest.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class MetricNamesTest { 7 | 8 | @Test 9 | public void metricNameForPodStatusAddsNullWhenStatusIsNull() { 10 | String expected = "kubernetes.cloud.pods.launch.status.null"; 11 | String actual = MetricNames.metricNameForPodStatus(null); 12 | 13 | Assert.assertEquals(expected, actual); 14 | } 15 | 16 | @Test 17 | public void metricNameForPodStatusAddsStatusValueIfNotNull() { 18 | String expected = "kubernetes.cloud.pods.launch.status.running"; 19 | String actual = MetricNames.metricNameForPodStatus("RUNNING"); 20 | 21 | Assert.assertEquals(expected, actual); 22 | } 23 | 24 | @Test 25 | public void metricNameForPodStatusChangeStatusToLowercase() { 26 | String expected = "kubernetes.cloud.pods.launch.status.failed"; 27 | String actual = MetricNames.metricNameForPodStatus("FaIlEd"); 28 | 29 | Assert.assertEquals(expected, actual); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/RestrictedPssSecurityInjectorTest.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes; 2 | 3 | import java.io.IOException; 4 | import org.csanchez.jenkins.plugins.kubernetes.pod.decorator.PodDecorator; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | public class RestrictedPssSecurityInjectorTest extends AbstractGoldenFileTest { 9 | @Before 10 | public void configureCloud() { 11 | cloud.setRestrictedPssSecurityContext(true); 12 | } 13 | 14 | @Override 15 | protected PodDecorator newDecorator() { 16 | return new RestrictedPssSecurityContextInjector(); 17 | } 18 | 19 | @Test 20 | public void simple() throws IOException { 21 | test("simple"); 22 | } 23 | 24 | @Test 25 | public void multiContainer() throws IOException { 26 | test("multiContainer"); 27 | } 28 | 29 | @Test 30 | public void existingSecurityContext() throws IOException { 31 | test("existingSecurityContext"); 32 | } 33 | 34 | @Test 35 | public void agentInjection() throws IOException { 36 | test("agentInjection"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineWebsocketRJRTest.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline; 2 | 3 | import java.net.UnknownHostException; 4 | import org.csanchez.jenkins.plugins.kubernetes.pipeline.steps.AssertBuildStatusSuccess; 5 | import org.csanchez.jenkins.plugins.kubernetes.pipeline.steps.RunId; 6 | import org.csanchez.jenkins.plugins.kubernetes.pipeline.steps.SetupCloud; 7 | import org.junit.Test; 8 | 9 | public class KubernetesPipelineWebsocketRJRTest extends AbstractKubernetesPipelineRJRTest { 10 | 11 | public KubernetesPipelineWebsocketRJRTest() throws UnknownHostException { 12 | super(new SetupCloud(true)); 13 | } 14 | 15 | @Test 16 | public void basicPipeline() throws Throwable { 17 | RunId runId = createWorkflowJobThenScheduleRun(); 18 | rjr.runRemotely(new AssertBuildStatusSuccess(runId)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/steps/AssertBuildLogMessage.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; 2 | 3 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; 4 | import org.jenkinsci.plugins.workflow.job.WorkflowRun; 5 | import org.jvnet.hudson.test.JenkinsRule; 6 | import org.jvnet.hudson.test.RealJenkinsRule; 7 | 8 | public class AssertBuildLogMessage implements RealJenkinsRule.Step { 9 | 10 | private final String message; 11 | private final RunId runId; 12 | 13 | public AssertBuildLogMessage(String message, RunId runId) { 14 | this.message = message; 15 | this.runId = runId; 16 | } 17 | 18 | @Override 19 | public void run(JenkinsRule r) throws Throwable { 20 | WorkflowJob p = r.jenkins.getItemByFullName(runId.name, WorkflowJob.class); 21 | WorkflowRun b = p.getBuildByNumber(runId.number); 22 | r.waitForMessage(message, b); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/steps/AssertBuildStatusSuccess.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; 2 | 3 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; 4 | import org.jenkinsci.plugins.workflow.job.WorkflowRun; 5 | import org.jvnet.hudson.test.JenkinsRule; 6 | import org.jvnet.hudson.test.RealJenkinsRule; 7 | 8 | public class AssertBuildStatusSuccess implements RealJenkinsRule.Step { 9 | private RunId runId; 10 | 11 | public AssertBuildStatusSuccess(RunId runId) { 12 | this.runId = runId; 13 | } 14 | 15 | @Override 16 | public void run(JenkinsRule r) throws Throwable { 17 | WorkflowJob p = r.jenkins.getItemByFullName(runId.name, WorkflowJob.class); 18 | WorkflowRun b = p.getBuildByNumber(runId.number); 19 | r.assertBuildStatusSuccess(r.waitForCompletion(b)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/steps/CreateWorkflowJobThenScheduleRun.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; 2 | 3 | import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; 4 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; 5 | import org.jenkinsci.plugins.workflow.job.WorkflowRun; 6 | import org.jvnet.hudson.test.JenkinsRule; 7 | import org.jvnet.hudson.test.RealJenkinsRule; 8 | 9 | /** 10 | * Creates a workflow job using the specified script, then schedules it and returns a reference to the run. 11 | */ 12 | public class CreateWorkflowJobThenScheduleRun implements RealJenkinsRule.Step2 { 13 | private String script; 14 | 15 | public CreateWorkflowJobThenScheduleRun(String script) { 16 | this.script = script; 17 | } 18 | 19 | @Override 20 | public RunId run(JenkinsRule r) throws Throwable { 21 | WorkflowJob project = r.createProject(WorkflowJob.class); 22 | project.setDefinition(new CpsFlowDefinition(script, true)); 23 | project.save(); 24 | WorkflowRun b = project.scheduleBuild2(0).get(); 25 | return new RunId(project.getFullName(), b.number); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/steps/CreateWorkflowJobThenScheduleTask.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; 2 | 3 | import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; 4 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; 5 | import org.jenkinsci.plugins.workflow.job.WorkflowRun; 6 | import org.jvnet.hudson.test.JenkinsRule; 7 | import org.jvnet.hudson.test.RealJenkinsRule; 8 | 9 | /** 10 | * Creates a workflow job using the specified script, then schedules it and returns a reference to the run. 11 | */ 12 | public class CreateWorkflowJobThenScheduleTask implements RealJenkinsRule.Step2 { 13 | private String script; 14 | 15 | public CreateWorkflowJobThenScheduleTask(String script) { 16 | this.script = script; 17 | } 18 | 19 | @Override 20 | public RunId run(JenkinsRule r) throws Throwable { 21 | WorkflowJob project = r.createProject(WorkflowJob.class); 22 | project.setDefinition(new CpsFlowDefinition(script, true)); 23 | project.save(); 24 | System.out.println("Scheduling build..."); 25 | WorkflowRun b = project.scheduleBuild2(0).getStartCondition().get(); 26 | System.out.println("Build scheduled..."); 27 | return new RunId(project.getFullName(), b.number); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/steps/RunId.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Lightweight, serializable reference to a run which can be passed around steps. 7 | */ 8 | public class RunId implements Serializable { 9 | String name; 10 | int number; 11 | 12 | RunId(String name, int number) { 13 | this.name = name; 14 | this.number = number; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public int getNumber() { 22 | return number; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/steps/package-info.java: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline.steps; 2 | /** 3 | * Reusable steps for tests relying on RealJenkinsRule. 4 | */ 5 | -------------------------------------------------------------------------------- /src/test/resources/kubenamespace: -------------------------------------------------------------------------------- 1 | test-namespace -------------------------------------------------------------------------------- /src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloudFIPSTest/certs/dsa1024: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDDzCCArygAwIBAgIUYBblXc5PhKw86bwvpcfBv/PxOmEwCwYJYIZIAWUDBAMC 3 | MEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJ 4 | bnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwHhcNMjQwNzE4MTU0MDAxWhcNMjQwODE3 5 | MTU0MDAxWjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G 6 | A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBvzCCATQGByqGSM44BAEw 7 | ggEnAoGBAN1Se68u8JFTdXrZ2ED2RDG89TRR51j1E7SPwlYItWQGAnJUkTRKyhYO 8 | 6oItvkuie/9HqjFVcz0hW1D0EfKKuJjv2VjkN07bQyZ9Kr92tfnkC2IOvbfDs8Ev 9 | g3GBOjKs7Bi9inOcQZCKt1ZeNd4j4jDrLPnisEc8urcBlbxnNCiHAh0A7PRieQst 10 | d6p4yVCVQp/fsjmUp+bL7phoR5jxNQKBgQC4K58rznGE8QmhSsUonv5Uf+gnnpDI 11 | 6eDiOUH/DpIDIMftK6AQ4wp6YY4pZP+dxfbBt9uimmfdyuvrO3i1oOD3UqmVSCwd 12 | Qome8YPGfxtTYYB/o05li7KPzHTqVcGXZQont9IK+uQaCwnzv/dsERol2F2aPMnD 13 | 6JE2hd/DCUWiqQOBhAACgYBeEMMpp5ROkIDZ5h4HeDDZztn1zWRrnsV89Cs6WcjR 14 | vbeumfVIoo06yws5tZdMfssrBjk+irKFKIU9edhiKcOjB8ssMJi+7tOEWEC9ooHo 15 | F6cOqiYmhLBhLrIyv5dZUe8RtyJRZaP+4bn3PbxZ7Cij8DWHntnwhEjrqlUp6vCq 16 | K6MhMB8wHQYDVR0OBBYEFPJmnQzXspNFvJNwPqxj//pvgzBlMAsGCWCGSAFlAwQD 17 | AgNAADA9AhwNYi4S6Cq9uh9KKBYz9jYdiJYjI2lmDnSFYGtQAh0AvZkHSf6BfSKE 18 | STBsggtQOqDvcao45reTjyaDcw== 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloudFIPSTest/certs/ecdsa192: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBwDCCAXagAwIBAgIUOwG28vjFm4KoiGieHrBRgzhrzGAwCgYIKoZIzj0EAwIw 3 | RTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGElu 4 | dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDA3MTgxNTQ4MzBaFw0yNDA4MTcx 5 | NTQ4MzBaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYD 6 | VQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwSjAUBgcqhkjOPQIBBgkrJAMD 7 | AggBAQQDMgAEpFiVE3YkcIaJVP9DsLIZE620gyX23AxQahhWjywp8hp+DKO4voH3 8 | HlKfdeDEZ5nfo1MwUTAdBgNVHQ4EFgQUCQxoboqlb8uG3RrOqtk4Dxil4xwwHwYD 9 | VR0jBBgwFoAUCQxoboqlb8uG3RrOqtk4Dxil4xwwDwYDVR0TAQH/BAUwAwEB/zAK 10 | BggqhkjOPQQDAgM4ADA1AhkAiI0732BOdYpjG1EgZ2y1Y1W9qLjgKLH7AhgwSQbA 11 | qPWq3wYiP1gZsVMavRL9K1ggspE= 12 | -----END CERTIFICATE----- 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloudFIPSTest/certs/ecdsa224: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBzzCCAX6gAwIBAgIUMxqDFkKRXOeP325owDz02IZomgUwCgYIKoZIzj0EAwIw 3 | RTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGElu 4 | dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDA3MTgxNTQ5MDVaFw0yNDA4MTcx 5 | NTQ5MDVaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYD 6 | VQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwUjAUBgcqhkjOPQIBBgkrJAMD 7 | AggBAQYDOgAEOuIfMAfhqilO6Q1VxiAjuQnTkpFH2MYcyFjyG9O2OG71KFuB4hC8 8 | r6NSSxVCx88TjKzcnm/u/HijUzBRMB0GA1UdDgQWBBQtPSBGTPqBRJQOVhf/c8Xh 9 | 5s0aOjAfBgNVHSMEGDAWgBQtPSBGTPqBRJQOVhf/c8Xh5s0aOjAPBgNVHRMBAf8E 10 | BTADAQH/MAoGCCqGSM49BAMCAz8AMDwCHAOWGI94ia/Ck3JgqIPFCGZUqR8uh9vC 11 | ovacsJACHC8VSwu0hEqevytqT7HH9E/DCMYORANJBZz5GyY= 12 | -----END CERTIFICATE----- 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloudFIPSTest/certs/not-a-cert: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | I'm not a certificate 3 | -----END CERTIFICATE----- 4 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloudFIPSTest/certs/rsa1024: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICZjCCAc+gAwIBAgIUJTYwlSTERKWU3FJaRvYtJ8o4LhEwDQYJKoZIhvcNAQEL 3 | BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM 4 | GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDA3MTcxNTUzMTJaFw0yNDA4 5 | MTYxNTUzMTJaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw 6 | HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwgZ8wDQYJKoZIhvcNAQEB 7 | BQADgY0AMIGJAoGBAMUOfI/nl8uloIH6YjuX+oRTaHUiT6KojtHGerfJXhzNran6 8 | G7xG8OjnionQ2o0TsePeN5OORg0kuvlaPL6gDlzpXwAa3WXO4kTTDgoprgNoWkAN 9 | lBjcIvdJhR+ZhdqDPFLjKJ4cDMhCVEJKXzyNZEa/ajVQTMhKMoBdJSFYqvYVAgMB 10 | AAGjUzBRMB0GA1UdDgQWBBQc34vePIqh3XpIuhuSuO7nkTQGGjAfBgNVHSMEGDAW 11 | gBQc34vePIqh3XpIuhuSuO7nkTQGGjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 12 | DQEBCwUAA4GBADF3TuD5RvzSK9ufD0Veq06iBe8jCgVa/gAVKXJcmpyP3CRw9koI 13 | hO+5RduA4XXY6oBplO76RH0bB21jDiYjpnP86V0/bgMYY3CLIYhr4SUfsXHTMWuN 14 | weBacm0rMTVd5EVKyrorBGbzFcDAQAsGA2MRoDu4PSeXxHDAjXfUPlIt 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtilsTest/decimal.yaml: -------------------------------------------------------------------------------- 1 | # Identical to octal.yaml with values converted to decimal 2 | apiVersion: "v1" 3 | kind: "Pod" 4 | spec: 5 | volumes: 6 | - configMap: 7 | name: cm1 8 | defaultMode: 493 9 | name: "volume1" 10 | - secret: 11 | secretName: secret1 12 | defaultMode: 484 13 | name: "volume2" 14 | - projected: 15 | sources: 16 | - configMap: 17 | name: cm2 18 | items: 19 | - key: username 20 | path: my-group/my-username 21 | mode: 256 22 | - secret: 23 | name: secret2 24 | items: 25 | - key: username 26 | path: my-group/my-username 27 | mode: 384 28 | defaultMode: 420 29 | name: "volume3" 30 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtilsTest/octal.yaml: -------------------------------------------------------------------------------- 1 | # Octal modes 2 | apiVersion: "v1" 3 | kind: "Pod" 4 | spec: 5 | volumes: 6 | - configMap: 7 | name: cm1 8 | defaultMode: 0755 9 | name: "volume1" 10 | - secret: 11 | secretName: secret1 12 | defaultMode: 0744 13 | name: "volume2" 14 | - projected: 15 | sources: 16 | - configMap: 17 | name: cm2 18 | items: 19 | - key: username 20 | path: my-group/my-username 21 | mode: 0400 22 | - secret: 23 | name: secret2 24 | items: 25 | - key: username 26 | path: my-group/my-username 27 | mode: 0600 28 | defaultMode: 0644 29 | name: "volume3" 30 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/RestrictedPssSecurityInjectorTest/existingSecurityContext-after.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: "v1" 3 | kind: "Pod" 4 | metadata: 5 | name: "simple" 6 | namespace: "jenkins" 7 | spec: 8 | containers: 9 | - env: 10 | - name: "JENKINS_SECRET" 11 | value: "my-little-secret" 12 | - name: "JENKINS_AGENT_NAME" 13 | value: "my-lovely-agent" 14 | - name: "REMOTING_OPTS" 15 | value: "-noReconnectAfter 1d" 16 | - name: "JENKINS_NAME" 17 | value: "my-lovely-agent" 18 | - name: "JENKINS_AGENT_WORKDIR" 19 | value: "/home/jenkins/agent" 20 | - name: "JENKINS_URL" 21 | value: "http://localhost/" 22 | image: "jenkins/inbound-agent" 23 | name: "jnlp" 24 | resources: 25 | limits: 26 | cpu: "1" 27 | memory: "768Mi" 28 | requests: 29 | cpu: "1" 30 | memory: "768Mi" 31 | securityContext: 32 | allowPrivilegeEscalation: true 33 | capabilities: 34 | drop: 35 | - "ALL" 36 | runAsNonRoot: true 37 | seccompProfile: 38 | type: "Localhost" 39 | volumeMounts: 40 | - mountPath: "/home/jenkins/agent" 41 | name: "workspace-volume" 42 | readOnly: false 43 | volumes: 44 | - emptyDir: 45 | medium: "" 46 | name: "workspace-volume" 47 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/RestrictedPssSecurityInjectorTest/existingSecurityContext-before.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: "v1" 3 | kind: "Pod" 4 | metadata: 5 | name: "simple" 6 | namespace: "jenkins" 7 | spec: 8 | containers: 9 | - env: 10 | - name: "JENKINS_SECRET" 11 | value: "my-little-secret" 12 | - name: "JENKINS_AGENT_NAME" 13 | value: "my-lovely-agent" 14 | - name: "REMOTING_OPTS" 15 | value: "-noReconnectAfter 1d" 16 | - name: "JENKINS_NAME" 17 | value: "my-lovely-agent" 18 | - name: "JENKINS_AGENT_WORKDIR" 19 | value: "/home/jenkins/agent" 20 | - name: "JENKINS_URL" 21 | value: "http://localhost/" 22 | image: "jenkins/inbound-agent" 23 | name: "jnlp" 24 | resources: 25 | limits: 26 | cpu: "1" 27 | memory: "768Mi" 28 | requests: 29 | cpu: "1" 30 | memory: "768Mi" 31 | securityContext: 32 | allowPrivilegeEscalation: true 33 | seccompProfile: 34 | type: "Localhost" 35 | volumeMounts: 36 | - mountPath: "/home/jenkins/agent" 37 | name: "workspace-volume" 38 | readOnly: false 39 | volumes: 40 | - emptyDir: 41 | medium: "" 42 | name: "workspace-volume" 43 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/RestrictedPssSecurityInjectorTest/simple-after.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: "v1" 3 | kind: "Pod" 4 | metadata: 5 | name: "simple" 6 | namespace: "jenkins" 7 | spec: 8 | containers: 9 | - env: 10 | - name: "JENKINS_SECRET" 11 | value: "my-little-secret" 12 | - name: "JENKINS_AGENT_NAME" 13 | value: "my-lovely-agent" 14 | - name: "REMOTING_OPTS" 15 | value: "-noReconnectAfter 1d" 16 | - name: "JENKINS_NAME" 17 | value: "my-lovely-agent" 18 | - name: "JENKINS_AGENT_WORKDIR" 19 | value: "/home/jenkins/agent" 20 | - name: "JENKINS_URL" 21 | value: "http://localhost/" 22 | image: "jenkins/inbound-agent" 23 | name: "jnlp" 24 | resources: 25 | limits: 26 | cpu: "1" 27 | memory: "768Mi" 28 | requests: 29 | cpu: "1" 30 | memory: "768Mi" 31 | securityContext: 32 | allowPrivilegeEscalation: false 33 | capabilities: 34 | drop: 35 | - "ALL" 36 | runAsNonRoot: true 37 | seccompProfile: 38 | type: "RuntimeDefault" 39 | volumeMounts: 40 | - mountPath: "/home/jenkins/agent" 41 | name: "workspace-volume" 42 | readOnly: false 43 | volumes: 44 | - emptyDir: 45 | medium: "" 46 | name: "workspace-volume" 47 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/RestrictedPssSecurityInjectorTest/simple-before.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: "v1" 3 | kind: "Pod" 4 | metadata: 5 | name: "simple" 6 | namespace: "jenkins" 7 | spec: 8 | containers: 9 | - env: 10 | - name: "JENKINS_SECRET" 11 | value: "my-little-secret" 12 | - name: "JENKINS_AGENT_NAME" 13 | value: "my-lovely-agent" 14 | - name: "REMOTING_OPTS" 15 | value: "-noReconnectAfter 1d" 16 | - name: "JENKINS_NAME" 17 | value: "my-lovely-agent" 18 | - name: "JENKINS_AGENT_WORKDIR" 19 | value: "/home/jenkins/agent" 20 | - name: "JENKINS_URL" 21 | value: "http://localhost/" 22 | image: "jenkins/inbound-agent" 23 | name: "jnlp" 24 | resources: 25 | limits: 26 | cpu: "1" 27 | memory: "768Mi" 28 | requests: 29 | cpu: "1" 30 | memory: "768Mi" 31 | volumeMounts: 32 | - mountPath: "/home/jenkins/agent" 33 | name: "workspace-volume" 34 | readOnly: false 35 | volumes: 36 | - emptyDir: 37 | medium: "" 38 | name: "workspace-volume" 39 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_envVar_keyValue.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - envVars: 7 | - envVar: 8 | key: key 9 | value: value 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_envVar_secret.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - envVars: 7 | - secretEnvVar: 8 | key: key 9 | secretName: secretName 10 | secretKey: secretKey 11 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_volume_configMap.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - volumes: 7 | - configMapVolume: 8 | configMapName: my-configmap 9 | mountPath: /mnt/path 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_volume_emptyDir.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - volumes: 7 | - emptyDirVolume: 8 | mountPath: /mnt/path 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_volume_emptyDir_memory.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - volumes: 7 | - emptyDirVolume: 8 | mountPath: /mnt/path 9 | memory: true 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_volume_genericEphemeral.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - volumes: 7 | - genericEphemeralVolume: 8 | mountPath: /mnt/path 9 | accessModes: ReadWriteMany 10 | storageClassName: test-storageclass 11 | requestsSize: 10Gi 12 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_volume_hostPath.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - volumes: 7 | - hostPathVolume: 8 | hostPath: /host/path 9 | mountPath: /mnt/path 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_volume_nfs.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - volumes: 7 | - nfsVolume: 8 | serverAddress: serverAddress 9 | serverPath: /path 10 | mountPath: /mnt/path 11 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_volume_pvc.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - volumes: 7 | - persistentVolumeClaim: 8 | claimName: my-claim 9 | mountPath: /mnt/path 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_workspaceVolume_dynamicPVC.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - hostNetwork: false 7 | label: "dynamic-pvc" 8 | name: "dynamic-pvc" 9 | workspaceVolume: 10 | dynamicPVC: 11 | accessModes: "ReadWriteOnce" 12 | requestsSize: "1" 13 | storageClassName: "hostpath" 14 | yamlMergeStrategy: "override" 15 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_workspaceVolume_emptyDir.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - workspaceVolume: 7 | emptyDir: {} 8 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_workspaceVolume_emptyDir_memory.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - workspaceVolume: 7 | emptyDir: 8 | memory: true 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_workspaceVolume_genericEphemeral.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - workspaceVolume: 7 | genericEphemeralVolume: 8 | storageClassName: test-storageclass 9 | accessModes: ReadWriteMany 10 | requestsSize: 10Gi 11 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_workspaceVolume_hostPath.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - workspaceVolume: 7 | hostPath: 8 | hostPath: "/host/path" 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_workspaceVolume_nfs.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - workspaceVolume: 7 | nfsWorkspaceVolume: 8 | serverAddress: "serverAddress" 9 | serverPath: "/path" 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/casc_workspaceVolume_pvc.yaml: -------------------------------------------------------------------------------- 1 | jenkins: 2 | clouds: 3 | - kubernetes: 4 | name: "kubernetes" 5 | templates: 6 | - workspaceVolume: 7 | persistentVolumeClaimWorkspaceVolume: 8 | claimName: "my-claim" 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/kubectlBuildWrapper_invalidCredentials.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | some-label: some-label-value 7 | spec: 8 | containers: 9 | - name: kubectl 10 | image: bitnami/kubectl:1.25.4 11 | command: 12 | - sleep 13 | args: 14 | - infinity 15 | ''' 16 | ) { 17 | node(POD_LABEL) { 18 | container('kubectl') { 19 | kubeconfig(serverUrl:'url',credentialsId:'id') { 20 | sh 'kubectl version' 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/kubectlBuildWrapper_missingCredentials.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | some-label: some-label-value 7 | spec: 8 | containers: 9 | - name: kubectl 10 | image: bitnami/kubectl:1.25.4 11 | command: 12 | - sleep 13 | args: 14 | - infinity 15 | ''' 16 | ) { 17 | node(POD_LABEL) { 18 | container('kubectl') { 19 | kubeconfig(serverUrl:'url',credentialsId:'abcd') { 20 | sh 'kubectl version' 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/badcontainername.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'badcontainerName_!', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | 5 | node(POD_LABEL) { 6 | stage('Run') { 7 | container('busybox') { 8 | sh """ 9 | will never run 10 | """ 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/badcontainernameyaml.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: """ 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | some-label: some-label-value 7 | spec: 8 | containers: 9 | - name: badcontainername_! 10 | image: busybox 11 | command: 12 | - cat 13 | tty: true 14 | - name: badcontainername2_! 15 | image: busybox 16 | command: 17 | - cat 18 | tty: true 19 | """ 20 | ) { 21 | 22 | node(POD_LABEL) { 23 | stage('Run') { 24 | container('busybox') { 25 | sh """ 26 | will never run 27 | """ 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/basicPipeline.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: '') { 2 | node(POD_LABEL) { 3 | sh 'true' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/basicWindows.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | spec: 5 | containers: 6 | - name: jnlp 7 | image: jenkins/inbound-agent:windowsservercore-1809 8 | nodeSelector: 9 | kubernetes.io/os: windows 10 | node.kubernetes.io/windows-build: 10.0.17763 11 | ''' 12 | ) { 13 | node(POD_LABEL) { 14 | bat 'dir' 15 | powershell 'Get-ChildItem Env: | Sort Name' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/bourneShellElsewhereInPath.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [containerTemplate(name: 'kaniko', image: 'gcr.io/kaniko-project/executor:debug', command: 'sleep', args: '99d')]) { 2 | node(POD_LABEL) { 3 | container(name: 'kaniko') { 4 | sh 'echo $PATH' 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/cancelOnlyRelevantQueueItem.groovy: -------------------------------------------------------------------------------- 1 | parallel k8s: { 2 | catchError(buildResult: 'SUCCESS') { 3 | podTemplate(yaml: ''' 4 | spec: 5 | containers: 6 | - name: jnlp 7 | image: some/invalid 8 | ''') { 9 | node(POD_LABEL) { 10 | sh 'false should never run' 11 | } 12 | } 13 | } 14 | echo 'cancelled pod item by now' 15 | }, unrelated: { 16 | node('special-agent') { 17 | echo 'ran on special agent' 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/closedWebSocketExit.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | node(POD_LABEL) { 5 | container('busybox') { 6 | sh 'sleep 5; echo have started user process; sleep 999' 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/computerCantBeConfigured.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | node(POD_LABEL) { 5 | semaphore 'pod' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/containerEnvironmentIsHonored.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | spec: 3 | containers: 4 | - name: jnlp 5 | image: jenkins/inbound-agent:3192.v713e3b_039fb_e-1 6 | # PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 7 | - name: alpine 8 | image: alpine:3.19.0 9 | # PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 10 | command: 11 | - sleep 12 | args: 13 | - infinity 14 | ''') { 15 | node(POD_LABEL) { 16 | echo "from Groovy outside container: ${env.PATH}" 17 | sh 'echo "from shell outside container: $PATH"' 18 | withEnv(['PATH+foo=/bar']) { 19 | echo "from Groovy outside container with override: ${env.PATH}" 20 | sh 'echo "from shell outside container with override: $PATH"' 21 | } 22 | container('alpine') { 23 | echo "from Groovy inside container: ${env.PATH}" 24 | sh 'echo "from shell inside container: $PATH"' 25 | withEnv(['PATH+foo=/bar']) { 26 | echo "from Groovy inside container with override: ${env.PATH}" 27 | sh 'echo "from shell inside container with override: $PATH"' 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/containerStatusErrorLogs.groovy: -------------------------------------------------------------------------------- 1 | //noinspection GrPackage 2 | pipeline { 3 | agent { 4 | kubernetes { 5 | yaml ''' 6 | apiVersion: v1 7 | kind: Pod 8 | spec: 9 | containers: 10 | - name: shell 11 | image: ubuntu 12 | command: 13 | - oops 14 | args: 15 | - infinity 16 | ''' 17 | } 18 | } 19 | stages { 20 | stage('Run') { 21 | steps { 22 | sh 'hostname' 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/containerTerminated.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml:''' 2 | spec: 3 | containers: 4 | - name: stress-ng 5 | image: polinux/stress-ng 6 | command: ['sh', '-c', "sleep 30; stress-ng --vm 2 --timeout 30s -v"] 7 | tty: true 8 | securityContext: 9 | runAsUser: 0 10 | privileged: true 11 | resources: 12 | limits: 13 | memory: "256Mi" 14 | requests: 15 | memory: "256Mi" 16 | ''') { 17 | node (POD_LABEL) { 18 | sh 'sleep 120' 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarative.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | label 'multiple labels' 5 | containerTemplate { 6 | name 'maven' 7 | image 'maven:3.3.9-jdk-8-alpine' 8 | command 'sleep' 9 | args '9999999' 10 | } 11 | podRetention onFailure() 12 | } 13 | } 14 | environment { 15 | CONTAINER_ENV_VAR = 'container-env-var-value' 16 | } 17 | stages { 18 | stage('Run maven') { 19 | steps { 20 | sh 'set' 21 | sh 'test -f /usr/bin/mvn' // checking backwards compatibility 22 | sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}" 23 | container('maven') { 24 | sh 'echo INSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 25 | sh 'mvn -version' 26 | } 27 | } 28 | } 29 | stage('Run maven with a different shell') { 30 | steps { 31 | container(name: 'maven', shell: '/bin/bash') { 32 | sh 'mvn -version' 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeCustomWorkspace.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | customWorkspace 'some/other/path' 5 | defaultContainer 'maven' 6 | yaml ''' 7 | metadata: 8 | labels: 9 | some-label: some-label-value 10 | class: KubernetesDeclarativeAgentTest 11 | spec: 12 | containers: 13 | - name: jnlp 14 | env: 15 | - name: CONTAINER_ENV_VAR 16 | value: jnlp 17 | - name: maven 18 | image: maven:3.3.9-jdk-8-alpine 19 | command: 20 | - cat 21 | tty: true 22 | env: 23 | - name: CONTAINER_ENV_VAR 24 | value: maven 25 | ''' 26 | } 27 | } 28 | 29 | stages { 30 | stage('Run maven') { 31 | steps { 32 | sh 'mvn -version' 33 | sh "echo Workspace dir is ${pwd()}" 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeFromYaml.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yaml ''' 5 | metadata: 6 | labels: 7 | some-label: some-label-value 8 | class: KubernetesDeclarativeAgentTest 9 | spec: 10 | containers: 11 | - name: jnlp 12 | env: 13 | - name: CONTAINER_ENV_VAR 14 | value: jnlp 15 | - name: maven 16 | image: maven:3.3.9-jdk-8-alpine 17 | command: 18 | - cat 19 | tty: true 20 | env: 21 | - name: CONTAINER_ENV_VAR 22 | value: maven 23 | - name: busybox 24 | image: busybox 25 | command: 26 | - cat 27 | tty: true 28 | env: 29 | - name: CONTAINER_ENV_VAR 30 | value: busybox 31 | ''' 32 | } 33 | } 34 | stages { 35 | stage('Run maven') { 36 | steps { 37 | sh 'set' 38 | sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}" 39 | container('maven') { 40 | sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 41 | sh 'mvn -version' 42 | } 43 | container('busybox') { 44 | sh 'echo BUSYBOX_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 45 | sh '/bin/busybox' 46 | } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeFromYamlFile.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yamlFile 'declarativeYamlFile.yml' 5 | } 6 | } 7 | options { 8 | // Because there's no way for the container to actually get at the git repo on the disk of the box we're running on. 9 | skipDefaultCheckout(true) 10 | } 11 | stages { 12 | stage('Run maven') { 13 | steps { 14 | sh 'set' 15 | sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}" 16 | container('maven') { 17 | sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 18 | sh 'mvn -version' 19 | } 20 | container('busybox') { 21 | sh 'echo BUSYBOX_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 22 | sh '/bin/busybox' 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeRetries.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yaml ''' 5 | spec: 6 | containers: 7 | - name: busybox 8 | image: busybox 9 | command: 10 | - sleep 11 | - 99d 12 | terminationGracePeriodSeconds: 3 13 | ''' 14 | defaultContainer 'busybox' 15 | retries 2 16 | } 17 | } 18 | stages { 19 | stage('Run') { 20 | steps { 21 | sh 'echo hello world' 22 | sh 'sleep 15' 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeShowRawYamlFalse.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | showRawYaml false 5 | yaml ''' 6 | metadata: 7 | labels: 8 | some-label: some-label-value 9 | class: KubernetesDeclarativeAgentTest 10 | spec: 11 | containers: 12 | - name: jnlp 13 | env: 14 | - name: CONTAINER_ENV_VAR 15 | value: jnlp 16 | ''' 17 | } 18 | } 19 | stages { 20 | stage('Run') { 21 | steps { 22 | sh 'set' 23 | container('jnlp') { 24 | sh 'echo CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeWithCreateContainerError.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yaml ''' 5 | apiVersion: v1 6 | kind: Pod 7 | metadata: 8 | labels: 9 | some-label: some-label-value 10 | spec: 11 | containers: 12 | - name: busybox 13 | image: busybox 14 | tty: true 15 | command: ['sh', '-c', "thiscommandshouldcreateanerror;"] 16 | ''' 17 | } 18 | } 19 | stages { 20 | stage('Run') { 21 | steps { 22 | container('busybox') { 23 | sh """ 24 | will never run 25 | """ 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeWithNamespaceFromYaml.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yaml ''' 5 | metadata: 6 | namespace: kubernetes-plugin-test-overridden-namespace 7 | labels: 8 | some-label: some-label-value 9 | class: KubernetesDeclarativeAgentTest 10 | spec: 11 | containers: 12 | - name: jnlp 13 | env: 14 | - name: CONTAINER_ENV_VAR 15 | value: jnlp 16 | - name: maven 17 | image: maven:3.3.9-jdk-8-alpine 18 | command: 19 | - cat 20 | tty: true 21 | env: 22 | - name: CONTAINER_ENV_VAR 23 | value: maven 24 | - name: busybox 25 | image: busybox 26 | command: 27 | - cat 28 | tty: true 29 | env: 30 | - name: CONTAINER_ENV_VAR 31 | value: busybox 32 | ''' 33 | } 34 | } 35 | stages { 36 | stage('Run maven') { 37 | steps { 38 | sh 'set' 39 | sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}" 40 | container('maven') { 41 | sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 42 | sh 'mvn -version' 43 | } 44 | container('busybox') { 45 | sh 'echo BUSYBOX_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 46 | sh '/bin/busybox' 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeWithNestedExplicitInheritance.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yaml ''' 5 | spec: 6 | containers: 7 | - name: golang 8 | image: golang:1.6.3-alpine 9 | command: 10 | - cat 11 | tty: true 12 | ''' 13 | } 14 | } 15 | stages { 16 | stage('Run maven') { 17 | agent { 18 | kubernetes { 19 | yaml ''' 20 | spec: 21 | containers: 22 | - name: maven 23 | image: maven:3.3.9-jdk-8-alpine 24 | command: 25 | - cat 26 | tty: true 27 | ''' 28 | } 29 | } 30 | steps { 31 | container('maven') { 32 | sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' 33 | sh 'mvn -version' 34 | } 35 | container('golang') { 36 | script { 37 | try { 38 | sh "go version" 39 | error("Should not inherit") 40 | } catch (e) { 41 | // ignored 42 | } 43 | } 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeWithNonexistentDockerImage.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | yaml ''' 5 | metadata: 6 | labels: 7 | some-label: some-label-value 8 | class: KubernetesDeclarativeAgentTest 9 | spec: 10 | containers: 11 | - name: jnlp 12 | env: 13 | - name: CONTAINER_ENV_VAR 14 | value: jnlp 15 | - name: container1 16 | image: nonexistent-docker-image 17 | command: 18 | - cat 19 | tty: true 20 | - name: maven 21 | image: maven:3.3.9-jdk-8-alpine 22 | command: 23 | - cat 24 | tty: true 25 | env: 26 | - name: CONTAINER_ENV_VAR 27 | value: maven 28 | ''' 29 | } 30 | } 31 | stages { 32 | stage('Run') { 33 | steps { 34 | container('container1') { 35 | sh """ 36 | will never run 37 | """ 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeYamlFile.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | labels: 3 | some-label: some-label-value 4 | class: KubernetesDeclarativeAgentTest 5 | spec: 6 | containers: 7 | - name: jnlp 8 | env: 9 | - name: CONTAINER_ENV_VAR 10 | value: jnlp 11 | - name: maven 12 | image: maven:3.3.9-jdk-8-alpine 13 | command: 14 | - cat 15 | tty: true 16 | env: 17 | - name: CONTAINER_ENV_VAR 18 | value: maven 19 | - name: busybox 20 | image: busybox 21 | command: 22 | - cat 23 | tty: true 24 | env: 25 | - name: CONTAINER_ENV_VAR 26 | value: busybox 27 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/decoratorFailure.groovy: -------------------------------------------------------------------------------- 1 | podTemplate { 2 | node(POD_LABEL) { 3 | sh 'true' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/directConnectionAgent.groovy: -------------------------------------------------------------------------------- 1 | podTemplate { 2 | node(POD_LABEL) { 3 | sh 'echo OK running' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/docker.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | kubernetes { 4 | containerTemplate { 5 | name 'docker' 6 | image 'docker:1.11' 7 | ttyEnabled true 8 | command 'cat' 9 | } 10 | } 11 | } 12 | stages { 13 | stage('Run maven') { 14 | steps { 15 | container('docker') { 16 | withDockerRegistry(registry: [credentialsId: 'ContainerExecDecoratorPipelineTest-docker']) { 17 | sh 'hostname' 18 | } 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/dynamicPVCVolume.groovy: -------------------------------------------------------------------------------- 1 | semaphore 'before' 2 | podTemplate(volumes: [dynamicPVC(requestsSize: '10Gi', mountPath: '/tmp/mountPath')], yaml:''' 3 | spec: 4 | securityContext: 5 | fsGroup: 1000 6 | ''') { 7 | 8 | node(POD_LABEL) { 9 | semaphore 'pod' 10 | container(name: 'jnlp') { 11 | sh 'cat /var/run/secrets/kubernetes.io/serviceaccount/namespace' 12 | git 'https://github.com/jenkinsci/kubernetes-plugin.git' 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/dynamicPVCWorkspaceVolume.groovy: -------------------------------------------------------------------------------- 1 | semaphore 'before' 2 | podTemplate(workspaceVolume: dynamicPVC(requestsSize: "10Gi"), yaml:''' 3 | spec: 4 | securityContext: 5 | fsGroup: 1000 6 | ''') { 7 | 8 | node(POD_LABEL) { 9 | semaphore 'pod' 10 | container(name: 'jnlp') { 11 | sh 'cat /var/run/secrets/kubernetes.io/serviceaccount/namespace' 12 | git 'https://github.com/jenkinsci/kubernetes-plugin.git' 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/envVarDollarSignEscaping.groovy: -------------------------------------------------------------------------------- 1 | podTemplate() { 2 | node(POD_LABEL) { 3 | env.THEVAR = "\$string\$with\$dollars" 4 | echo "from Groovy: ${env.THEVAR}" 5 | sh 'echo "outside container: $THEVAR"' 6 | container('jnlp') { 7 | sh 'echo "inside container: $THEVAR"' 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/errorPod.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml:''' 2 | spec: 3 | containers: 4 | - name: jnlp 5 | command: 6 | - 'sh' 7 | - '-ec' 8 | - 'echo Foo; exit 1' 9 | ''') { 10 | node(POD_LABEL) { 11 | sh 'true' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/garbageCollection.groovy: -------------------------------------------------------------------------------- 1 | podTemplate { 2 | node(POD_LABEL) { 3 | echo 'Running on remote agent' 4 | sh 'sleep 600' 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/getContainerLog.groovy: -------------------------------------------------------------------------------- 1 | //noinspection GrPackage 2 | podTemplate { 3 | node(POD_LABEL) { 4 | stage('container log') { 5 | containerLog 'jnlp' 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/getContainerLogWithRestart.groovy: -------------------------------------------------------------------------------- 1 | //noinspection GrPackage 2 | podTemplate() 3 | { 4 | node(POD_LABEL) { 5 | stage('container log') { 6 | sh 'for i in `seq 1 5`; do echo $i; sleep 5; done' 7 | containerLog 'jnlp' 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/handleEviction.groovy: -------------------------------------------------------------------------------- 1 | podTemplate { 2 | retry(count: 2, conditions: [kubernetesAgent()]) { 3 | node(POD_LABEL) { 4 | semaphore 'pod' 5 | sh 'sleep 1' 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/imageWithoutAgent.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(agentContainer:'foo', 2 | agentInjection: true, 3 | yaml:''' 4 | spec: 5 | containers: 6 | - name: foo 7 | image: eclipse-temurin:22.0.2_9-jre 8 | ''') { 9 | node(POD_LABEL) { 10 | sh 'true' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/imageWithoutAgentNoJava.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(agentContainer:'foo', 2 | agentInjection: true, 3 | yaml:''' 4 | spec: 5 | containers: 6 | - name: foo 7 | image: busybox 8 | ''') { 9 | node(POD_LABEL) { 10 | sh 'true' 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/inheritFrom.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(inheritFrom: 'standard') { 2 | node(POD_LABEL) { 3 | sh 'true' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/interruptedPod.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [containerTemplate(name: 'shell', image: 'ubuntu', command: 'sleep', args: '99d')]) { 2 | node(POD_LABEL) { 3 | container('shell') { 4 | // Note that trap apparently does not work in Ubuntu [da]sh or Busybox [a]sh. 5 | sh(/set +x; bash -c 'trap "echo shut down gracefully" EXIT; echo starting to sleep; sleep 9999999'/) 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/interruptedPodWindows.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | spec: 5 | containers: 6 | - name: jnlp 7 | image: jenkins/inbound-agent:windowsservercore-1809 8 | - name: shell 9 | image: mcr.microsoft.com/powershell:preview-windowsservercore-1809 10 | command: 11 | - powershell 12 | args: 13 | - Start-Sleep 14 | - 999999 15 | nodeSelector: 16 | kubernetes.io/os: windows 17 | node.kubernetes.io/windows-build: 10.0.17763 18 | ''') { 19 | node(POD_LABEL) { 20 | container('shell') { 21 | powershell 'try {Write-Host starting to sleep; Start-Sleep 999999} finally {Write-Host shut down gracefully}' 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/invalidImageGetsCancelled.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | spec: 3 | containers: 4 | - name: jnlp 5 | image: some/invalid 6 | ''') { 7 | node(POD_LABEL) { 8 | sh 'false' 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/invalidPodGetsCancelled.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | spec: 3 | containers: 4 | - name: invalid-container 5 | ''') { 6 | node(POD_LABEL) { 7 | sh 'This will never run' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/jenkinsSecretHidden.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | node (POD_LABEL) { 5 | semaphore 'pod' 6 | stage('Run') { 7 | sh 'env | sort' 8 | container('busybox') { 9 | sh 'env | sort' 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/jnlpWorkingDir.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:3283.v92c105e0f819-7', workingDir: '/home/jenkins'), 3 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat') 4 | ]) { 5 | node (POD_LABEL) { 6 | stage('Run') { 7 | sh 'env | sort' 8 | container('busybox') { 9 | sh 'env | sort' 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/mergeYaml.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: """ 2 | spec: 3 | containers: 4 | - name: jnlp 5 | env: 6 | - name: VAR1 7 | value: 1 8 | """) { 9 | podTemplate(yamlMergeStrategy: merge(), 10 | yaml: """ 11 | spec: 12 | containers: 13 | - name: jnlp 14 | env: 15 | - name: VAR2 16 | value: 1 17 | """) { 18 | node(POD_LABEL){ 19 | sh '[ "$VAR1" = "1" ]' 20 | sh '[ "$VAR1" = "$VAR2" ]' 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/noDelayProvisionerCallsListener.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | node (POD_LABEL) { 5 | stage('Run') { 6 | container('busybox') { 7 | sh 'echo foo' 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/nullLabelSupportsRestart.groovy: -------------------------------------------------------------------------------- 1 | node { 2 | stage('Run') { 3 | container('busybox') { 4 | sh 'for i in `seq 1 10`; do echo $i; sleep 5; done' 5 | } 6 | echo 'finished the test!' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/octalPermissions.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | spec: 3 | volumes: 4 | - name: jenkins-agent 5 | projected: 6 | sources: 7 | - secret: 8 | name: container-secret 9 | items: 10 | - key: password 11 | path: my-group/my-password 12 | mode: 0777 13 | ''') { 14 | node(POD_LABEL){ 15 | sh 'true' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/overrideYaml.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: """ 2 | spec: 3 | containers: 4 | - name: jnlp 5 | env: 6 | - name: VAR1 7 | value: 1 8 | """) { 9 | podTemplate(yaml: """ 10 | containers: 11 | - name: jnlp 12 | env: 13 | - name: VAR2 14 | value: 1 15 | """) { 16 | node(POD_LABEL){ 17 | sh '["$VAR1" != "$VAR2"]' 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/podDeadlineExceeded.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml:''' 2 | spec: 3 | activeDeadlineSeconds: 30 4 | ''') { 5 | node(POD_LABEL) { 6 | sh 'sleep 120' 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/podDeadlineExceededGlobalTemplate.groovy: -------------------------------------------------------------------------------- 1 | node('podDeadlineExceededGlobalTemplate') { 2 | sh 'sleep 120' 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/podStatusErrorLogs.groovy: -------------------------------------------------------------------------------- 1 | //noinspection GrPackage 2 | pipeline { 3 | agent { 4 | kubernetes { 5 | yaml ''' 6 | apiVersion: v1 7 | kind: Pod 8 | spec: 9 | containers: 10 | - name: shell 11 | image: ubuntu 12 | command: 13 | - sleep 14 | args: 15 | - infinity 16 | nodeSelector: 17 | disktype: ssd 18 | ''' 19 | } 20 | } 21 | stages { 22 | stage('Run') { 23 | steps { 24 | sh 'hostname' 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/podStatusNoErrorLogs.groovy: -------------------------------------------------------------------------------- 1 | //noinspection GrPackage 2 | pipeline { 3 | agent { 4 | kubernetes { 5 | yaml ''' 6 | apiVersion: v1 7 | kind: Pod 8 | spec: 9 | containers: 10 | - name: shell 11 | image: ubuntu 12 | command: 13 | - sleep 14 | args: 15 | - infinity 16 | ''' 17 | } 18 | } 19 | stages { 20 | stage('Run') { 21 | steps { 22 | sh 'hostname' 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/podTemplateWithMultipleLabels.groovy: -------------------------------------------------------------------------------- 1 | node('label1') { 2 | semaphore 'pod' 3 | sh 'echo "It works"' 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/restartDuringPodLaunch.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | spec: 5 | nodeSelector: 6 | disktype: special 7 | ''') { 8 | node(POD_LABEL) { 9 | sh 'true' 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runDirContext.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | 5 | node(POD_LABEL) { 6 | stage('Run') { 7 | container('busybox') { 8 | sh 'mkdir hz' 9 | sh 'echo "initpwd is -$(pwd)-"' 10 | dir('hz') { 11 | sh 'echo "dirpwd is -$(pwd)-"' 12 | } 13 | sh 'echo "postpwd is -$(pwd)-"' 14 | } 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPod.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(label: '$NAME', containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | semaphore 'podTemplate' 5 | node ('$NAME') { 6 | semaphore 'pod' 7 | stage('Run') { 8 | container('busybox') { 9 | echo "container=$POD_CONTAINER" 10 | sh """ 11 | ## durable-task plugin generates a script.sh file. 12 | ## 13 | echo "script file: \$(find ../../.. -iname script.sh))" 14 | echo "script file contents: \$(find ../../.. -iname script.sh -exec cat {} \\;)" 15 | test -n "\$(cat \"\$(find ../../.. -iname script.sh)\")" 16 | """ 17 | } 18 | } 19 | } 20 | } 21 | semaphore 'after-podtemplate' 22 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodFromYaml.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: """ 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | some-label: some-label-value 7 | spec: 8 | containers: 9 | - name: busybox 10 | image: busybox 11 | command: 12 | - cat 13 | tty: true 14 | env: 15 | - name: CONTAINER_ENV_VAR 16 | value: container-env-var-value 17 | - name: CONTAINER_ENV_VAR_FROM_SECRET 18 | valueFrom: 19 | secretKeyRef: 20 | key: password 21 | name: container-secret 22 | """ 23 | ) { 24 | 25 | node(POD_LABEL) { 26 | stage('Run') { 27 | container('busybox') { 28 | sh '''set +x 29 | ## durable-task plugin generates a script.sh file. 30 | ## 31 | echo "script file: $(find ../../.. -iname script.sh))" 32 | echo "script file contents: $(find ../../.. -iname script.sh -exec cat {} \\;)" 33 | echo INSIDE_CONTAINER_ENV_VAR_FROM_SECRET = $CONTAINER_ENV_VAR_FROM_SECRET or `echo $CONTAINER_ENV_VAR_FROM_SECRET | tr [a-z] [A-Z]` 34 | test -n "$(cat "$(find ../../.. -iname script.sh)")" 35 | ''' 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodNested.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(label: '$NAME-parent', containers: [ 2 | containerTemplate(name: 'golang', image: 'golang:1.6.3-alpine', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | 5 | podTemplate(containers: [ 6 | containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: '/bin/cat'), 7 | ]) { 8 | 9 | node(POD_LABEL) { 10 | stage('Nested') { 11 | container('maven') { 12 | sh "mvn -version" 13 | } 14 | } 15 | stage('Parent') { 16 | container('golang') { 17 | sh "go version" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodNestedExplicitInherit.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(label: '$NAME-parent', containers: [ 2 | containerTemplate(name: 'golang', image: 'golang:1.6.3-alpine', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | 5 | podTemplate(inheritFrom: '', containers: [ 6 | containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: '/bin/cat'), 7 | ]) { 8 | 9 | node(POD_LABEL) { 10 | stage('Nested') { 11 | container('maven') { 12 | sh "mvn -version" 13 | } 14 | } 15 | stage('Parent') { 16 | container('golang') { 17 | script { 18 | try { 19 | sh "go version" 20 | error("Should not inherit") 21 | } catch (e) { 22 | // ignored 23 | } 24 | } 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithDifferentShell.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | 5 | node(POD_LABEL) { 6 | stage('Run') { 7 | container(name:'busybox', shell: '/bin/bash') { 8 | sh """ 9 | echo "Run BusyBox shell" 10 | """ 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithLivenessProbe.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(volumes: [emptyDirVolume(mountPath: '/my-mount')], containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: 'cat', livenessProbe: containerLivenessProbe( execArgs: 'uname -a', initialDelaySeconds: 5, timeoutSeconds: 1, failureThreshold: 3, periodSeconds: 10, successThreshold: 1)) 3 | ]) { 4 | 5 | node(POD_LABEL) { 6 | stage('Wait for Liveness Probe') { 7 | container('busybox') { 8 | sh 'sleep 6 && echo "Still alive"' 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithMultipleContainers.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(volumes: [emptyDirVolume(mountPath: '/my-mount')], containers: [ 2 | containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'), 3 | containerTemplate(name: 'golang', image: 'golang:1.6.3-alpine', ttyEnabled: true, command: 'cat') 4 | ]) { 5 | 6 | node(POD_LABEL) { 7 | sh "echo My Kubernetes Pipeline" 8 | sh "ls /" 9 | 10 | stage('Run maven') { 11 | container('maven') { 12 | sh 'mvn -version' 13 | } 14 | } 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithRestart.groovy: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline 2 | 3 | podTemplate(containers: [ 4 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 5 | ]) { 6 | 7 | node(POD_LABEL) { 8 | stage('Run') { 9 | container('busybox') { 10 | sh 'mkdir hz' 11 | sh 'echo "initpwd is -$(pwd)-"' 12 | dir('hz') { 13 | sh 'echo "dirpwd is -$(pwd)-"' 14 | } 15 | sh 'echo "postpwd is -$(pwd)-"' 16 | } 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithRestartWithLongSleep.groovy: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline 2 | 3 | podTemplate(containers: [ 4 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 5 | ]) { 6 | 7 | node(POD_LABEL) { 8 | stage('Run') { 9 | container('busybox') { 10 | sh 'for i in `seq 1 10`; do echo $i; sleep 5; done' 11 | } 12 | echo 'finished the test!' 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithRestartWithMultipleContainerCalls.groovy: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline 2 | 3 | podTemplate(idleMinutes: 0, containers: [ 4 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 5 | ]) { 6 | 7 | node(POD_LABEL) { 8 | stage('Run') { 9 | container('busybox') { 10 | sh 'for i in `seq 1 10`; do echo $i; sleep 5; done' 11 | sh 'ps' 12 | } 13 | container('busybox') { 14 | sh 'ps' 15 | } 16 | echo 'finished the test!' 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithRetention.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(podRetention: always(), containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | 5 | node(POD_LABEL) { 6 | stage('Run') { 7 | container('busybox') { 8 | sh """ 9 | echo "Running pod with retention" 10 | """ 11 | } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodWithShowRawYamlFalse.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(showRawYaml: false, yaml: """ 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | some-label: some-label-value 7 | spec: 8 | containers: 9 | - name: busybox 10 | image: busybox 11 | command: 12 | - cat 13 | tty: true 14 | env: 15 | - name: CONTAINER_ENV_VAR 16 | value: container-env-var-value 17 | - name: CONTAINER_ENV_VAR_FROM_SECRET 18 | valueFrom: 19 | secretKeyRef: 20 | key: password 21 | name: container-secret 22 | """ 23 | ) { 24 | 25 | node(POD_LABEL) { 26 | stage('Run') { 27 | container('busybox') { 28 | sh ''' 29 | echo "anything" 30 | ''' 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runWithActiveDeadlineSeconds.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(label: '$NAME', activeDeadlineSeconds: 10, containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 3 | ]) { 4 | semaphore 'podTemplate' 5 | node ('$NAME') { 6 | stage('Run') { 7 | container('busybox') { 8 | sh """ 9 | echo "Hello from container!" 10 | """ 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runWithCloudOverriddenNamespace.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(volumes: [emptyDirVolume(mountPath: '/my-mount')]) { 2 | 3 | node(POD_LABEL) { 4 | semaphore 'pod' 5 | container(name: 'jnlp') { 6 | sh 'cat /var/run/secrets/kubernetes.io/serviceaccount/namespace' 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runWithStepOverriddenNamespace.groovy: -------------------------------------------------------------------------------- 1 | // Step namespace should have priority over anything else. 2 | podTemplate( 3 | namespace: '$OVERRIDDEN_NAMESPACE', 4 | volumes: [emptyDirVolume(mountPath: '/my-mount')]) { 5 | 6 | node(POD_LABEL) { 7 | semaphore 'pod' 8 | container(name: 'jnlp') { 9 | sh 'cat /var/run/secrets/kubernetes.io/serviceaccount/namespace' 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/secretMaskingWindows.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | spec: 5 | containers: 6 | - name: jnlp 7 | image: jenkins/inbound-agent:windowsservercore-1809 8 | env: 9 | - name: POD_ENV_VAR_FROM_SECRET 10 | valueFrom: 11 | secretKeyRef: 12 | key: password 13 | name: pod-secret 14 | - name: shell 15 | image: mcr.microsoft.com/powershell:preview-windowsservercore-1809 16 | command: 17 | - powershell 18 | args: 19 | - Start-Sleep 20 | - 999999 21 | env: 22 | - name: CONTAINER_ENV_VAR_FROM_SECRET 23 | valueFrom: 24 | secretKeyRef: 25 | key: password 26 | name: container-secret 27 | nodeSelector: 28 | kubernetes.io/os: windows 29 | node.kubernetes.io/windows-build: 10.0.17763 30 | ''') { 31 | node(POD_LABEL) { 32 | powershell 'echo "INSIDE_POD_ENV_VAR_FROM_SECRET = $Env:POD_ENV_VAR_FROM_SECRET or $($Env:POD_ENV_VAR_FROM_SECRET.ToUpper())"' 33 | container('shell') { 34 | powershell 'echo "INSIDE_CONTAINER_ENV_VAR_FROM_SECRET = $Env:CONTAINER_ENV_VAR_FROM_SECRET or $($Env:CONTAINER_ENV_VAR_FROM_SECRET.ToUpper())"' 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/showRawYamlFalseInherited.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(showRawYaml: false) { podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | spec: 5 | containers: 6 | - name: busybox 7 | image: busybox 8 | command: 9 | - cat 10 | tty: true 11 | env: 12 | - name: CONTAINER_ENV_VAR 13 | value: container-env-var-value 14 | ''' 15 | ) 16 | { 17 | node(POD_LABEL) { 18 | stage('Run') { 19 | container('busybox') { 20 | sh ''' 21 | echo "anything" 22 | ''' 23 | } 24 | } 25 | } 26 | } } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/sidecarWorkingDir.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat', workingDir: '/src') 3 | ]) { 4 | node (POD_LABEL) { 5 | stage('Run') { 6 | sh '[ "$(pwd)" = "/home/jenkins/agent/workspace/$JOB_NAME" ]' 7 | container('busybox') { 8 | sh '[ "$(pwd)" = "/src/workspace/$JOB_NAME" ]' 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/sshagent.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(containers: [ 2 | containerTemplate(name: 'ssh-client', image: 'kroniak/ssh-client:3.6', ttyEnabled: true, command: 'cat') 3 | ]) { 4 | node(POD_LABEL) { 5 | stage('container log') { 6 | container('ssh-client') { 7 | sshagent (credentials: ['ContainerExecDecoratorPipelineTest-sshagent']) { 8 | sh 'env' 9 | sh 'ssh-add -L' 10 | sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com' 11 | } 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/substituteEnv.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(annotations: [podAnnotation(key: 'hack', value: 'xxx${HOME}xxx')]) { 2 | node(POD_LABEL) { 3 | sh ':' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/supportComputerEnvVars.groovy: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | 4 | kubernetes{ 5 | containerTemplate{ 6 | name 'openjdk' 7 | image 'openjdk' 8 | workingDir '/home/jenkins/agent' 9 | ttyEnabled true 10 | command 'cat' 11 | args '' 12 | } 13 | } 14 | } 15 | 16 | 17 | stages{ 18 | stage('Build') { 19 | steps { 20 | 21 | sh 'echo DEFAULT_BUILD_NUMBER: ${BUILD_NUMBER}' 22 | container('jnlp') 23 | { 24 | sh 'echo JNLP_BUILD_NUMBER: ${BUILD_NUMBER}' 25 | } 26 | container('openjdk'){ 27 | sh 'echo OPENJDK_BUILD_NUMBER: ${BUILD_NUMBER}' 28 | } 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/taskListenerAfterRestart.groovy: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline 2 | 3 | podTemplate(containers: [ 4 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 5 | ]) { 6 | node (POD_LABEL) { 7 | container('busybox') { 8 | sh 'sleep 9999999' 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/taskListenerAfterRestart_multipleLabels.groovy: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline 2 | 3 | podTemplate(label: 'label1 label2', 4 | containers: [ 5 | containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), 6 | ]) { 7 | node ('label1') { 8 | container('busybox') { 9 | sh 'sleep 9999999' 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/terminatedPod.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | spec: 3 | containers: 4 | - name: busybox 5 | image: busybox 6 | command: 7 | - sleep 8 | - 99d 9 | terminationGracePeriodSeconds: 3 10 | ''') { 11 | retry(count: 2, conditions: [kubernetesAgent()]) { 12 | node(POD_LABEL) { 13 | container('busybox') { 14 | sh 'echo hello world' 15 | sh 'sleep 15' 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/terminatedPodAfterRestart.groovy: -------------------------------------------------------------------------------- 1 | package org.csanchez.jenkins.plugins.kubernetes.pipeline 2 | 3 | podTemplate(yaml: ''' 4 | spec: 5 | containers: 6 | - name: busybox 7 | image: busybox 8 | command: 9 | - sleep 10 | - 99d 11 | terminationGracePeriodSeconds: 3 12 | ''') { 13 | retry(count: 2, conditions: [kubernetesAgent()]) { 14 | node(POD_LABEL) { 15 | container('busybox') { 16 | sh 'sleep 15' 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/webSocketAgent.groovy: -------------------------------------------------------------------------------- 1 | podTemplate { 2 | node(POD_LABEL) { 3 | sh 'echo OK running' 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/windowsContainer.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | spec: 5 | containers: 6 | - name: jnlp 7 | image: jenkins/inbound-agent:windowsservercore-1809 8 | - name: shell 9 | image: mcr.microsoft.com/powershell:preview-windowsservercore-1809 10 | command: 11 | - powershell 12 | args: 13 | - Start-Sleep 14 | - 999999 15 | nodeSelector: 16 | kubernetes.io/os: windows 17 | node.kubernetes.io/windows-build: 10.0.17763 18 | ''' 19 | ) { 20 | node(POD_LABEL) { 21 | bat 'mkdir subdir' 22 | withEnv(["STUFF=some value"]) { 23 | dir('subdir') { 24 | container('shell') { 25 | bat 'dir' 26 | powershell 'Get-ChildItem Env: | Sort Name' 27 | bat 'echo got stuff: %STUFF%' 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/windowsRestart.groovy: -------------------------------------------------------------------------------- 1 | podTemplate(yaml: ''' 2 | apiVersion: v1 3 | kind: Pod 4 | spec: 5 | containers: 6 | - name: jnlp 7 | image: jenkins/inbound-agent:windowsservercore-1809 8 | - name: shell 9 | image: mcr.microsoft.com/powershell:preview-windowsservercore-1809 10 | command: 11 | - powershell 12 | args: 13 | - Start-Sleep 14 | - 999999 15 | nodeSelector: 16 | kubernetes.io/os: windows 17 | node.kubernetes.io/windows-build: 10.0.17763 18 | ''') { 19 | node(POD_LABEL) { 20 | container('shell') { 21 | powershell 'for ($i = 0; $i -lt 10; $i++) {echo "sleeping #$i"; Start-Sleep 5}' 22 | } 23 | echo 'finished the test!' 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pod-jnlp-nullenv.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | spec: 4 | containers: 5 | - name: jnlp 6 | image: jnlp-agent 7 | env: 8 | -------------------------------------------------------------------------------- /src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pod-overrides.yaml: -------------------------------------------------------------------------------- 1 | metadata: 2 | namespace: yaml-namespace 3 | spec: 4 | containers: 5 | - name: jnlp 6 | image: jenkins-jnlp-override 7 | securityContext: 8 | runAsUser: 3000 9 | runAsGroup: 4000 10 | volumeMounts: 11 | - mountPath: /home/jenkins/agent 12 | name: host-volume 13 | resources: 14 | limits: 15 | cpu: 2 16 | memory: 2Gi 17 | requests: 18 | cpu: 200m 19 | memory: 256Mi 20 | volumes: 21 | - name: host-volume 22 | hostPath: 23 | path: /host/data 24 | --------------------------------------------------------------------------------