Zalenium: How to set docker path for Jenkins local? docker: command not found

202 views
Skip to first unread message

afsal backer

unread,
Aug 24, 2020, 2:44:43 PM8/24/20
to Selenium Users
I am trying to run Zalenium from Jenkins local installed on my Mac. I am able to execute tests locally from Eclipse by first spinning up docker from Terminal. Now I am trying to execute tests via pipeline.

Here's the pipeline code:

    pipeline {
        agent any
    tools
    {
        maven 'M2_HOME'
        jdk 'JAVA_HOME'
     }
        stages {
            stage('Code and Dependencies'){
                parallel{
                stage('Checkout Code'){
                    steps{
                         git(url: 'https://github.com/xxxxx')
                    }
                }
                
            stage('Initialise Tools') {
              steps {
                tool(name: 'M2_HOME', type: 'maven')
                tool(name: 'JAVA_HOME', type: 'jdk')
              }
            }
                
                stage('Install Dependencies'){
                    steps{
                        sh 'docker pull elgalu/selenium'
                        sh 'docker pull dosel/zalenium'
                    }
                }
            }
            }
        }
    }

Global tools configuration:
Docker Installation : /usr/local/bin/

    testuser@blr-ml-test ~ % which docker
    /usr/local/bin/docker

    testuser@blr-ml-test ~ % docker -v
    Docker version 19.03.12, build 48a66213fe

But when I run the job, I get:

 `/Users/test/.jenkins/workspace/ZaleniumPipeline@tmp/durable-16989357/script.sh: line 1: docker: command not found`

I am able to run from local Jenkins though. I suspect this is a path setting issue. Tried few similar questions but none worked for me. What am I doing wrong?

Sobeer Singh

unread,
Aug 26, 2020, 2:17:06 AM8/26/20
to Selenium Users
Try below update in your pipeline code:
sh '/usr/local/bin/docker pull elgalu/selenium'
sh '/usr/local/bin/docker pull dosel/zalenium'

afsal backer

unread,
Aug 26, 2020, 2:33:04 AM8/26/20
to Selenium Users
This works. Also found /Applications/Docker.app/Contents/Resources/bin/docker ____ as Execute Shell also works. But shouldn't there be an option to set path permanently  and only use actual docker commands?

So I did a Terminal vim .bash_profile and added:
export JAVA_HOME=$(/usr/libexec/java_home)
export M2_HOME=/Users/abacker/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin
export Docker_Home=/usr/local/bin
export PATH=$PATH:$Docker_Home

And on Jenkins Global Tools Config Docker section I added:
Name: Docker_Home
Root: /usr/local/binBut this fails with same error.


This is what I see in Jenkins logs when execute shell is: /usr/local/bin/docker images
Commit message: "Merge pull request #65 from Test-IT/saucelabsReplica"
> git rev-list --no-walk 03d6955a8ad9d7b85c79ed3789030ea9da930f9a # timeout=10
[ZaleniumSingle] $ /bin/sh -xe /var/folders/8v/z503nb6n6m9byyvlb6g5bf9c0000gp/T/jenkins3464149420441257087.sh
+ /usr/local/bin/docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gm4afsal/cheers2019 latest 8aed96ebfcda 2 days ago 4.01MB
elgalu/selenium latest 799e7781f0c4 13 days ago 1.57GB
selenium/node-chrome-debug latest 04414d01df54 3 weeks ago 947MB

Sobeer Singh

unread,
Aug 26, 2020, 3:02:48 AM8/26/20
to Selenium Users
I don't think docker name change will make a difference. It is just the name. I am not sure if adding docker path in PATH variable will work.

afsal backer

unread,
Aug 26, 2020, 3:05:24 AM8/26/20
to Selenium Users
Does that mean specifying the whole path in pipeline script is the standard approach?
Reply all
Reply to author
Forward
0 new messages