Permission Denied running flyway in Jenkins pipeline

  docker, flyway, jenkins, jenkins-pipeline

I’m attempting to run flyway migrations from our Jenkins pipeline. I can’t seem to make it work and I’m currently receiving the message flyway: Permission denied

I’d appreciate any feedback.

Here is the stage in my Jenkinsfile

stage('Apply DB changes') {
    def flyway = docker.image('flyway/flyway')
    flyway.inside('-v /Database/migrations:/flyway/sql --entrypoint='){
        sh "flyway"
    }
}

Here is the console output for that stage

[Pipeline] stage
[Pipeline] { (Apply DB changes)
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . flyway/flyway
.
[Pipeline] withDockerContainer
jenkins-slave1 does not seem to be running inside a container
$ docker run -t -d -u 2002:2002 -v /Database/migrations:/flyway/sql --entrypoint= -w /var/lib/jenkins/workspace/nd_Dev_my.api_flyway -v /var/lib/jenkins/workspace/nd_Dev_my.api_flyway:/var/lib/jenkins/workspace/nd_Dev_my.api_flyway:rw,z -v /var/lib/jenkins/workspace/[email protected]:/var/lib/jenkins/workspace/[email protected]:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** flyway/flyway cat
$ docker top e2a9c6e66332142dfeaca0d3050fb43b8bf0360b709b9199a9ae314b9f513931 -eo pid,comm
[Pipeline] {
[Pipeline] sh
+ flyway
/var/lib/jenkins/workspace/[email protected]/durable-8264b583/script.sh: 1: flyway: Permission denied
[Pipeline] }

Source: Docker Questions

LEAVE A COMMENT