[JIRA] (JENKINS-57704) Run JNLP container as side car to default build container

11 views
Skip to first unread message

hendrik@halkow.com (JIRA)

unread,
May 27, 2019, 12:34:01 PM5/27/19
to jenkinsc...@googlegroups.com
Hendrik Halkow updated an issue
 
Jenkins / Improvement JENKINS-57704
Run JNLP container as side car to default build container
Change By: Hendrik Halkow
Summary: Run jnlp JNLP container as side car to default build container
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

jenkins-ci@carlossanchez.eu (JIRA)

unread,
May 27, 2019, 12:55:02 PM5/27/19
to jenkinsc...@googlegroups.com
Carlos Sanchez commented on Improvement JENKINS-57704
 
Re: Run JNLP container as side car to default build container

you can do it in declarative with defaultContainer

hendrik@halkow.com (JIRA)

unread,
May 27, 2019, 3:03:02 PM5/27/19
to jenkinsc...@googlegroups.com

you can do it in declarative with defaultContainer

That's exactly the point: I think this shouldn't be in the pipeline code. The pipeline should be agnostic to the technology that runs the build. Beside that, this requires me having a `kubernetes` block inside the agent block, which prevents me from having a `labels` block. And the labels inside the `kubernetes` block work differently than regular Jenkins labels.

hendrik@halkow.com (JIRA)

unread,
May 27, 2019, 3:13:02 PM5/27/19
to jenkinsc...@googlegroups.com
Hendrik Halkow edited a comment on Improvement JENKINS-57704
bq. you can do it in declarative with defaultContainer


That's exactly the point: I think this shouldn't be in the pipeline code. The pipeline should be agnostic to the technology that runs the build. Beside that, this requires me having a `kubernetes` block inside the agent block, which prevents me from having a `labels` block. And the labels inside the `kubernetes` block work differently than regular Jenkins labels.


Edit: I just it with defaultContainers and it doesn't even work. This is my pipeline code:
{code}
pipeline {
  agent none
  stages {
    stage('Test') {
      agent {
        kubernetes {
          defaultContainer 'build'
          label 'centos'
        }
      }
      steps {
        sh """
          set -x
          ls -la /opt
          sleep 1000
        """
      }
    }
  }
}
{code}

And this is the result:
{code}
21:05:59  [Pipeline] withEnv
21:05:59  [Pipeline] {
21:05:59  [Pipeline] container
21:05:59  [Pipeline] {
21:05:59  [Pipeline] sh
21:05:59  /bin/sh: line 1: cd: /code/workspace/xxxxx_hello-pipeline_feat_k8s: No such file or directory
21:05:59  sh: /code/workspace/xxxxx_hello-pipeline_feat_k8s@tmp/durable-2e2ff7d6/jenkins-log.txt: No such file or directory
21:05:59  sh: /code/workspace/xxxxx_hello-pipeline_feat_k8s@tmp/durable-2e2ff7d6/jenkins-result.txt.tmp: No such file or directory
21:05:59  mv: cannot stat ‘/code/workspace/xxxxx_hello-pipeline_feat_k8s@tmp/durable-2e2ff7d6/jenkins-result.txt.tmp’: No such file or directory
21:05:58   > git rev-list --no-walk ef30fb54796f5bcad9f6f968f280a608eb46f1b7 # timeout=10
21:11:07  process apparently never started in /code/workspace/xxxxx_hello-pipeline_feat_k8s@tmp/durable-2e2ff7d6
21:11:07  [Pipeline] }
21:11:07  [Pipeline] // container
21:11:07  [Pipeline] }
21:11:07  [Pipeline] // withEnv
21:11:07  [Pipeline] }
21:11:08  [Pipeline] // node
21:11:08  [Pipeline] }
21:11:08  [Pipeline] // podTemplate
21:11:08  [Pipeline] }
21:11:08  [Pipeline] // stage
21:11:08  [Pipeline] End of Pipeline
21:11:09  
21:11:09  GitHub has been notified of this commit’s build result
21:11:09  
21:11:09  ERROR: script returned exit code -2
21:11:09  Finished: FAILURE
{code}

hendrik@halkow.com (JIRA)

unread,
May 27, 2019, 3:23:02 PM5/27/19
to jenkinsc...@googlegroups.com


Edit 2: This is how I wish the agent block should look like:
{code}
agent {
  // Pod template with that label and default container
  // are configured inside Jenkins.
  // Nothing about Kubernetes in the pipeline here.
  // The build can even run on a VM.
  label 'centos'
}
{code}

jglick@cloudbees.com (JIRA)

unread,
Jun 4, 2019, 8:16:02 AM6/4/19
to jenkinsc...@googlegroups.com

This issue seems to be specifically about the Declarative syntax, rather than how the plugin’s underlying steps work (and thus what the Scripted syntax would look like).

The kubernetes block is required inside agent to activate this plugin. Different agent launching technologies work fundamentally differently and there is no use obscuring which has been selected.

Given JENKINS-57830 (the use of Jenkins labels is an implementation detail that most Jenkinsfile authors should not need to pay attention to) and some related changes, we could probably boil down the syntax to something like

agent {
  kubernetes {
    containerTemplate {
      image 'maven:3.6.1-jdk-11'
      defaultContainer: true
    }
  }
}

without loss of backward compatibility and with minimal redundancy in syntactic options.

jglick@cloudbees.com (JIRA)

unread,
Jul 16, 2019, 3:30:02 PM7/16/19
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
 
Change By: Jesse Glick
Labels: jnlp jnlp -slave k8s kubernetes kubernetes-plugin pipeline ux

jglick@cloudbees.com (JIRA)

unread,
Jul 16, 2019, 3:43:43 PM7/16/19
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Unassigned
Change By: Jesse Glick
Assignee: Carlos Sanchez
Reply all
Reply to author
Forward
0 new messages