This issue is related to the "Docker Pipeline" plugin ("docker-workflow") 
which has an issue when trying to determine if the executor (master or 
agent) is running inside a container.

See issue/PR #120 of "docker-workflow-plugin", in particular 
https://github.com/jenkinsci/docker-workflow-plugin/pull/120#issuecomment-357284756
 
which is for the standard "docker".

Here is my work list items to diagnose this:

* The tutorials are working quite well with some older version of Docker 
(example: 17.09)
* When the tutorial is not working, wee the build failing, and before the 
error message "sh....not found...", we have a difference in the logs: it 
says "Jenkins does not seem to be running inside a container".
  - We can also see the "docker run" commands issued by the docker-workflow 
plugin: 
    > BEFORE: "--volumes-from <SOME_CONTAINER_ID>"
    > AFTER: "-v /var/jenkins_home/....:/var/jenkins_home/....."
* This log message come from this piece of code on the plugin (v.1.14 when 
writing those 
lines): 
https://github.com/jenkinsci/docker-workflow-plugin/blob/docker-workflow-1.14/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L158-L182
* As Far as I Understand, The function "getContainerIdIfContainerized()" is 
returning the Optional.absent() String when it is not working, so the 
condition is false.
* This function is implemented 
here: 
https://github.com/jenkinsci/docker-workflow-plugin/blob/docker-workflow-1.14/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L311
 
* Before diving in the code (and because I really suck at reading/writing 
code), I first checked my cgroup self file to see what it looks like 
(smelling Pattern 
issue...): https://gist.github.com/dduportal/67f965dd935b4fb7d316b798f2a6c2ef
  - While someone with the tutorial working got 
this: https://gist.github.com/dduportal/0ac5e5c76043e95fa0b5ff85c1b0c93e
* See the diff? "/docker/" vs. "/docker-ce/".
* Searching the Internet made it easy to 
catch https://github.com/jenkinsci/docker-workflow-plugin/pull/120 .

=> The constant used to get the cgroup pattern to catch has to be improved 
(short term) in order to catch the new patterns: "docker-ce", "docker-ee", 
"kubernetes" ones and "ecs".
=> This to be solved need to see an update of the plugin with this fix at 
least. Long term would be to find another way of detecting the container 
inception, or providing customizable configs for this.



On Monday, January 22, 2018 at 5:49:08 AM UTC+1, Giles Gaskell wrote:
>
> Thanks for your speedy reply Mark,
>
> I ended up raising a bug report here: 
> https://issues.jenkins-ci.org/browse/JENKINS-49063
>
> This behavior is definitely manifesting itself through the Jenkins LTS 
> release 2.89.3. In fact, I'm using a recent update of the 
> "jenkinsci/blueocean" Docker image - see the "Environment" details in the 
> bug report above.
>
> Incidentally, I also tried this out on the latest weekly release of the 
> "jenkins/jenkins" Docker image (i.e. 2.103) but received a different error 
> because unlike the "jenkinsci/blueocean" Docker image's container, the 
> "docker" command doesn't appear to be available in the "jenkins/jenkins" 
> container. Hence, I got the error:
>
> ...
>
>  
>
> [simple-java-maven-app] Running shell script
>
> + docker pull maven:3-alpine
>
> /var/jenkins_home/workspace/simple-java-maven-app@tmp/durable-9030abcd/script.sh:
>  
>> 2: 
>> /var/jenkins_home/workspace/simple-java-maven-app@tmp/durable-9030abcd/script.sh:
>>  
>> docker: not found 
>
>
>> [Pipeline] } 
>
>  
>
> ...
>
>
> Giles
>
> On Monday, January 22, 2018 at 2:03:31 PM UTC+11, Mark Waite wrote:
>>
>> That sounds like a bug.  
>>
>> Is this with the long-term support release (2.89.3) or with a weekly 
>> release (like 2.102).
>>
>> If it is a weekly release, is the same problem visible in a weekly 
>> release prior to 2.102?  The 2.102 release includes a security improvement 
>> (JEP-200) which detected several places that need further changes.
>>
>> If it is with LTS or an earlier weekly release, submit a bug report ( 
>> https://wiki.jenkins.io/display/JENKINS/How+to+report+an+issue ).
>>  
>> Mark Waite
>>
>> On Sun, Jan 21, 2018 at 7:04 PM Giles Gaskell <ggas...@cloudbees.com> 
>> wrote:
>>
>>> Hi all,
>>>
>>> I recently saw someone raise this issue 
>>> <https://github.com/jenkins-docs/simple-java-maven-app/issues/11> in 
>>> the GitHub repository that the Build a Java app with Maven 
>>> <https://jenkins.io/doc/tutorials/build-a-java-app-with-maven/> tutorial 
>>> uses.
>>>
>>> This issue shows the output of the Pipeline run with the typical 
>>> failures that happen fairly early on:
>>>
>>> sh: can't create 
>>>> /var/jenkins_home/workspace/sjma@tmp/durable-cd13b59e/jenkins-log.txt: 
>>>> nonexistent directory
>>>> sh: can't create 
>>>> /var/jenkins_home/workspace/sjma@tmp/durable-cd13b59e/jenkins-result.txt: 
>>>> nonexistent directory
>>>
>>>
>>> I even began running though this tutorial myself and encountered the 
>>> same problem... I would also expect the same problematic output in most of 
>>> the other tutorials.
>>>
>>> Essentially, the tutorial asks the reader to do the following:
>>>
>>>    1. Install Jenkins in Docker (locally on your computer).
>>>    2. Fork the sample GitHub repository and clone it locally to your 
>>>    computer.
>>>    3. Create your Jenkinsfile within your locally cloned repo on the 
>>>    your computer.
>>>    4. Run the declarative Pipeline in Jenkins.
>>>
>>> Puzzled as to why this might be happening, I found this closed issue 
>>> <https://github.com/jenkinsci/docker/issues/626> in the jenkinsci/docker 
>>> GitHub project which seems to shed a bit of light on the problem. However, 
>>> I wasn't quite sure if the actual problem (be it a change or issue with the 
>>> Jenkins Docker image or Docker itself) was clearly identified.
>>>
>>> Since lots of people use these tutorials (i.e. from September/October 
>>> last year, over 900 people have forked the simple-java-maven-app repository 
>>> used by this first tutorial), I am keen to identify the cause of this issue 
>>> (and potentially fix the tutorial content asap so that the tutorials will 
>>> start working again).
>>>
>>> Therefore, does anyone here have any suggestions as what might be the 
>>> cause of this issue and/or how I might amend the tutorials to get them 
>>> working again. For example, are there additional options I could add to the 
>>> docker 
>>> run ... command?
>>>
>>> Many thanks,
>>> Giles.
>>>
>>> P.S. I am keen to keep using the Jenkins Docker container method for 
>>> running Jenkins since this is a convenient way to get Jenkins up and 
>>> running locally.
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Jenkins Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to jenkinsci-use...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-users/841d29f5-2ea5-48a0-bb2b-339a6f11a918%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jenkinsci-users/841d29f5-2ea5-48a0-bb2b-339a6f11a918%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a7be4835-a68c-4502-8071-827a3ccb0a4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to