首页 > 解决方案 > 在詹金斯中找不到 docker-compose 命令

问题描述

我正在尝试使用 Jenkins 连接到 bitbucket 并使用 docker-compose 构建图像并将构建的图像推送到 docker-hub。我可以使用 Jenkins 管道连接到 bitbucket。但是,在构建管道时,我在 Jenkins 中遇到了 docker-compose 错误。

我已经尝试在我的管道中包含 docker-compose 的完整路径,但我仍然遇到同样的错误。也试过,把它放在一个路径变量中,这也导致了同样的错误。下面是代码。docker-compose 文件的路径与“克隆 Git”步骤中的 bitbucket 克隆完全相同。任何帮助表示赞赏,谢谢!

pipeline {
  environment {
        registry = "xxxx/xxx"
        registryCredential = 'xxxxx'

        dockerImage = ''
  }
  agent any
  stages {
    stage('Cloning Git') {
      steps {
        git branch: 'dev',
        credentialsId: 'xxxx',
        url: 'xxxx'
      }
    }
    stage('Printing content') {
      steps {
        sh 'pwd; ls -l;'
      }
    }
    stage('Building Image') {
      steps {
        sh './usr/bin/docker-compose -f docker-compose.yml up -d --build'
      }
    }



    }

  }

标签: dockerjenkinsdocker-composecontinuous-integrationjenkins-pipeline

解决方案


推荐阅读