YoussHark
YoussHark

Reputation: 608

docker volume issue inside jenkins steps

Inside a jenkins stage and steps, I am trying to build an image; run the container with a volume and then stash a file in order to unstash it after.
But unfortunately it doesn't create the volume and doesn't stash.

Here is the jenkins code

stage('Android') {
          agent {
            label buildLabel()
          }
          steps {
            checkout scm
            sh '''
              mkdir -p `pwd`/build_target
              docker build -t android_build -f docker/Dockerfile.android .
              docker run --rm -v `pwd`/build_target:/home/gradle/reactapp/android/app/build/outputs/apk/ android_build
              ls -la `pwd`/build_target/*
            '''
            stash includes: 'build_target/app-release.apk', name: 'apk'
            androidApkUpload apkFilesPattern: '**/app-release.apk', googleCredentialsId: 'jenkins_apk_upload', trackName: 'internal'
          }

        }

Upvotes: 0

Views: 174

Answers (1)

paco alcacer
paco alcacer

Reputation: 391

My solution would be configuring a ENV in Global properties on http://jenkins-server/configure. enter image description here

In build script, I can use the env to get the shared path in the host. enter image description here

And in all agent hosts, I mount the same NFS path to it. mount -t nfs 10.6.188.1:/root /root/pacotest1 on every node

Upvotes: 1

Related Questions