Shared Library does not run inside a Pod/Container

I have a question regarding the execution of shared Library methods within a K8s POD/container.

I have a simple shared library example, which does, among other things, create a folder, yes, it does other things and in fact that doesn’t matter now. The fact is that it works, I have been testing Docker agents in Jenkins. https://github.com/faustobranco/devops-db/tree/master/infrastructure/pipelines/lib-utilities

But when I create it in K8, using multi-containers, as in the example pipeline below, the method does not run within the indicated container. The sh, sever call is just for testing and indicating that I am in the correct container.

@Library('devopsdb-global-lib') _

import devopsdb.utilities.Utilities
def obj_Utilities = new Utilities(this)                        

pipeline {
    agent {
//        kubernetes {
//            yamlFile 'file-pod/resources/pods/file-pod.yaml'
//            retries 2
//        }
        kubernetes {
            yaml """
        apiVersion: v1
        kind: Pod
        metadata:
          labels:
            some-label: "pod-template-${env.BUILD_ID}"
        spec:
          containers:
          - name: container-1
            image: registry.devops-db.internal:5000/img-jenkins-devopsdb:2.0
            env:
            - name: CONTAINER_NAME
              value: "container-1"
            volumeMounts:
            - name: shared-volume
              mountPath: /mnt
            command:
            - cat
            tty: true
          - name: container-2
            image: ubuntu:22.04
            env:
            - name: CONTAINER_NAME
              value: "container-2"
            volumeMounts:
            - name: shared-volume
              mountPath: /mnt
            command:
            - cat
            tty: true
          volumes:
          - name: shared-volume
            emptyDir: {}            
        """
        }
    }
    options { timestamps ()
        skipDefaultCheckout(true)
    }
    stages {
        stage('Environment') {
            steps {
                container('container-1') {
                    script {
                        sh 'echo $CONTAINER_NAME > /mnt/shared_volume.txt'
                        def str_folder = "/mnt/pipelines/resources"
                        def str_folderCheckout = "/pip"
                        obj_Utilities.CreateFolders(str_folder)
                        sh 'sleep 10m'
                        obj_Utilities.SparseCheckout('[email protected]:infrastructure/pipelines/resources.git',
                                'master',
                                str_folderCheckout,
                                'usr-service-jenkins',
                                str_folder)
                        sh 'sleep 1s'
                        sh "PIP_CONFIG_FILE=${str_folder}${str_folderCheckout}/pip-devops.conf pip install devopsdb"
                    }
                }
            }
        }
    } 
}

The result of the check inside the Container: It is clear that the folder is not created, but the file is.

Again, the issue is not creating the folder itself, that’s what sh solves, the problem is that shared doesn’t run inside the container, this prevents me, for example, from using the lib for sparse checkout.

kubectl get pods --namespace jenkins-devopsdb
NAME                                                              READY   STATUS    RESTARTS     AGE
infrastructure-pipelines-tests-test-file-pod-28-hvhmc-btx-zp14d   3/3     Running   0            61s


kubectl get pods infrastructure-pipelines-tests-test-file-pod-28-hvhmc-btx-zp14d --namespace jenkins-devopsdb -o="custom-columns=NAME:.metadata.name,INIT-CONTAINERS:.spec.initContainers[*].name,CONTAINERS:.spec.containers[*].name"
NAME                                                          INIT-CONTAINERS   CONTAINERS
infrastructure-pipelines-tests-test-file-pod-28-hvhmc-btx-zp14d   <none>            container-1,container-2,jnlp



kubectl exec -i -t infrastructure-pipelines-tests-test-file-pod-28-hvhmc-btx-zp14d --container container-1 --namespace jenkins-devopsdb -- /bin/bash
root@infrastructure-pipelines-tests-test-file-pod-28-hvhmc-btx-zp14d:/pipeline# ls -lah /mnt/
total 12K
drwxrwxrwx 2 root root 4.0K Jun 26 10:24 .
drwxr-xr-x 1 root root 4.0K Jun 26 10:24 ..
-rw-r--r-- 1 root root   12 Jun 26 10:24 shared_volume.txt

If I let the pipeline continue:

11:39:36  ERROR: Checkout failed
11:39:36  Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 172.21.5.156/172.21.5.156:26427
11:39:36  at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787)
11:39:36  at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
11:39:36  at hudson.remoting.Channel.call(Channel.java:1003)
11:39:36  at hudson.FilePath.act(FilePath.java:1226)
11:39:36  at hudson.FilePath.act(FilePath.java:1215)
11:39:36  at hudson.FilePath.mkdirs(FilePath.java:1406)
11:39:36  at hudson.plugins.git.GitSCM.createClient(GitSCM.java:845)
11:39:36  at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1294)
11:39:36  at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:136)
11:39:36  at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:101)
11:39:36  at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:88)
11:39:36  at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
11:39:36  at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
11:39:36  at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
11:39:36  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
11:39:36  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
11:39:36  at java.base/java.lang.Thread.run(Thread.java:840)
11:39:36  java.nio.file.AccessDeniedException: /mnt/pipelines

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