Jenkins pipeline shell set $HOME to /var/www

59 views
Skip to first unread message

Changqin Xie

unread,
Jun 8, 2017, 12:18:27 PM6/8/17
to Jenkins Users
Using the following Jenkinsfile:
#!/usr/bin/env groovy

pipeline {
    agent any

    stages {
        stage('Deploy') {
            steps {
                sh 'echo $HOME'
            }
        }
    }
}

And I get $HOME == /var/www
Why isn't it being "/home/www-data"? By the way, I am running Jenkins under the user www-data.

R. Tyler Croy

unread,
Jun 8, 2017, 12:50:55 PM6/8/17
to jenkins...@googlegroups.com
(replies inline)
I would be willing to bet that the home directory for the www-data user is
actually set to `/var/www` in /etc/passwd.

Most Linux packages set the home-directory for that user to /var/www



- R. Tyler Croy

------------------------------------------------------
Code: <https://github.com/rtyler>
Chatter: <https://twitter.com/agentdero>
xmpp: rty...@jabber.org

% gpg --keyserver keys.gnupg.net --recv-key 1426C7DC3F51E16F
------------------------------------------------------
signature.asc

Kirill Peskov

unread,
Jun 9, 2017, 2:55:26 AM6/9/17
to jenkins...@googlegroups.com
If you're working with Debian and/or its derivatives, default user for
webserver is www-data, group www-data and the default home directory for
that user is /var/www

Check if this string exists if /etc/passwd

www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin

BTW, in RedHat, CentOS, Fedora, etc. user is apache, group apache and
the home dir is /usr/share/httpd


Cheers,
Kirill
Reply all
Reply to author
Forward
0 new messages