Details
-
Type:
Improvement
-
Status: Closed (View Workflow)
-
Priority:
Critical
-
Resolution: Fixed
-
Component/s: pipeline-model-definition-plugin
-
Labels:None
-
Similar Issues:
Description
The agent section in Declarative Pipelines should be pluggable, so that we can have multiple implementations with their own logic. Once JENKINS-37011 is done, we'll be able to implement steps that compose other steps, which is what we're going for here.
So we'll have, e.g., a "label" provider for just running on an agent directly, a "docker" provider for Docker Pipeline, a "kubernetes" provider for the Kubernetes plugin, a "docker-slaves" provider for the Docker Slaves plugin, etc.
Attachments
Activity
Andrew Bayer ok so I am not quite sure what you got up to here (there are no tests/examples in the PR at least that I could see so not 100% sure).
named parameters seem to make sense. What about an executor that takes more config than may easily fit in a named parameter? Or will they always take named parameters (but one of them may be a config map specific to that type of agent plugin?)
So in the simplest case of label:
agent label:"foo"
Right?
Then docker:
agent docker:'image name' (optional label:'executor label here') - based on your last comment (although that doesnt' have an explicit image which Peter suggests is nice).
Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-declarative-agent/pom.xml
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgent.java
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentDescriptor.java
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentScript.java
pipeline-model-definition/pom.xml
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Agent.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Any.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipeline.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Label.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/None.java
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/NoneScript.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d07730e7939fee12e9c287a0537e67570edf52c9
Log:
JENKINS-38433 Make the agent section pluggable.
This is very preliminary - I expect a lot more iteration. But it
works. The DeclarativeAgent* classes are in a separate plugin so that
they can be depended on by other plugins with minimal transitive
dependencies in the process (just workflow-cps-plugin currently - may
try to find a way to narrow that down further).
Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-api/pom.xml
pipeline-model-declarative-agent/pom.xml
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgent.java
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentDescriptor.java
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentScript.java
pipeline-model-definition/pom.xml
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Agent.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Any.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipeline.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Label.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/None.java
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/NoneScript.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelAndOtherFieldAgent.java
pipeline-model-definition/src/test/resources/agentAnyInStage.groovy
pipeline-model-definition/src/test/resources/agentTypeOrdering.groovy
pipeline-model-definition/src/test/resources/errors/agentMissingRequiredParam.groovy
pipeline-model-definition/src/test/resources/errors/agentUnknownParamForType.groovy
pipeline-model-definition/src/test/resources/errors/unknownAgentType.groovy
pipeline-model-definition/src/test/resources/errors/unknownBareAgentType.groovy
pipeline-model-definition/src/test/resources/json/agentTypeOrdering.json
pipeline-model-definition/src/test/resources/json/errors/agentMissingRequiredParam.json
pipeline-model-definition/src/test/resources/json/errors/agentUnknownParamForType.json
pipeline-model-definition/src/test/resources/json/errors/unknownAgentType.json
pipeline-model-definition/src/test/resources/json/errors/unknownBareAgentType.json
pipeline-model-definition/src/test/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelAndOtherFieldAgentScript.groovy
pom.xml
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/9e9b0bbb67f8417e458672e6c70a49b989a062fa
Log:
Merge pull request #35 from abayer/pluggable-agent
JENKINS-38433 Make the agent section pluggable.
Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/83a83f675427...9e9b0bbb67f8
Bulk closing resolved issues.
Ok, I've just about got the agent label: 'foo', docker: 'bar' syntax working. It does lead to one caveat - we can't introduce any bare indicators like none and any outside of this plugin itself.