无法使用Jenkins CloudFoundryPlugin将docker映像推送到Cloud Foundry

时间:2019-07-08 15:52:05

标签: docker jenkins jenkins-plugins cloudfoundry

我正在尝试使用Cloud Foundry插件将Docker注册表映像推送到CloudFoundry。该应用程序在暂存步骤中失败。

我已在manifest.yml文件中添加了注册表URL和用户名,并在cf docs中提到的环境变量中提供了密码。

Jenkinsfile代码段:

stage ('Dev_Deployment') {
            steps{
                sh 'export CF_DOCKER_PASSWORD=$USER_CREDENTIALS_PSW'
                pushToCloudFoundry(
                  target: 'https://api.sys.dev.example.io',
                  credentialsId: 'pcfcreds',
                  organization: 'pcforg',
                  cloudSpace: 'pcfspace',
                  manifestChoice: [manifestFile: 'manifest.yml']
                )
              }
          }

manifest.yml代码:

---
applications:
- name: App-1
  memory: 1G
  instances: 1
  host: App-1
  disk_quota: 1G
  docker:
    image: registry-dev.apps.dev.example.io/app-1
    username: user1

我希望将Docker映像作为PCF中的应用程序进行部署。

但是我在应用程序登台时遇到了错误

java.lang.IllegalStateException: Application SpringDemo-3 failed during staging

它实际上并不将其视为docker部署。而是将其视为正常的应用程序部署并搜索buildpack。

2019-07-08T19:23:14.80+0530 [STG/0] ERR None of the buildpacks detected a compatible application

是否有示例管道将安全注册表中的docker映像推送到CloudFoundry?

1 个答案:

答案 0 :(得分:0)

我已经经历过Cloud Foundry Plugin Release Notes(直到2.3.1版),但没有找到可将docker镜像推送到Cloud Foundry的功能。

因此,我发现以下代码段是一种解决方法,其中CF CLI已用于推送docker映像,而不是使用Cloud Foundry插件。

stage ('Dev_Deployment') {
    steps{
        sh 'pwd'
        sh 'which cf'
        sh 'cf --version'
        sh 'cf login -a $CF_API_ENDPOINT -u $CF_CREDENTIALS_USER -p $CF_CREDENTIALS_PASSWORD'
        sh 'cf t -o $CF_ORG -s $CF_SPACE'
        sh 'CF_DOCKER_PASSWORD=$DOCKER_CREDENTIALS_PASSWORD cf push'
    }
}