Home directory missing in Docker container launched by Jenkins (Jenkins uses its own OS user in container)

I am just setting up Jenkins as a CI/build system on a host. Some pipelines would use Docker container for the build process. Jenkins itself is installed on the host system (so no Docker-in-Docker scenario!).

TL;DR:

Jenkins would “inject” the OS-Jenkins user into the Docker build container. Since the OS-Jenkins user is not known in the container, this leads to several difficulties. One of them: the executing user in the container has no HOME directory.

Problem arising: manual “git clone” commands in the build process would fail.

In more detail:

If you have a Jenkinsfile like this:

node {
    docker.image("bitnami/minideb:latest").inside() {
        echo "I am ..."
        sh "id"
    }
}

The Jenkins docker plugin would start the container with:

docker run -t -d -u 114:121 -w ...... bitnami/minideb:latest

Thus, it uses the local OS Jenkins user (happens to be UID 114 in my case) in the container. Since this user is not known in the container, it has e.g. no HOME directory.

Later in the build process, I need to execute

conan config install [email protected]:group/tools/conan.git

Nevermind that this is Conan. If you don’t know the “conan” tool: it is a dependency manager for C++. The only important thing here is that this above command would fetch conan settings from a repo and try to store the setting in a folder ~/.conan. AND it does some “git clone” commands on its own when trying to resolve the dependencies.

I think where it stucks is when conan tries to perform manual “git clone” steps.

It tried to boil it down:

#!groovy

def docker_image = "cr.myownrepos.com/group/proj1/prj/algotest-launcher:1.6"

node {
    docker.withRegistry('https://cr.myownrepo.com/', '78e560d3-73d7-4f36-a884-3001a913b202'){
        docker.image(docker_image).inside() {

            stage('Build') {
                sshagent(['my_sshKey']) {
                    sh "export HOME=/tmp"
                    sh "git clone [email protected]:bmd-se/group/conan.git"
                }
            }
        }
    }
}

So this is only a “git clone”. Result: FAILURE with this output:

+ git clone [email protected]:bmd-se/tools/conan.git
Cloning into 'conan'...
No user exists for uid 114
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

In this case I cannot use the Jenkins git plugin instead, since the git command would be executed by the “conan” lib on its own.

So my question(s):

How can I provide a “normal” user from the container’s point of view, with a HOME directory and the ability to save something in it?

Or is there some other way I can conan to successfully clone some git repos?

Maybe the problem simply boils down to:

How can I manually do a “git clone somerepo” in a container launched by Jenkins docker plugin (when Jenkins injects a non-existent user with UID 114 into the container?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật