1
votes

I am trying to push a docker registry image to CloudFoundry using the Cloud Foundry Plugin. The application fails in the staging step.

I have added registry url and username in manifest.yml file and providing the password in the environment variable as mentioned in cf docs.

Jenkinsfile snippet:

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 code:

---
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

I expect the docker image to be deployed as an application in PCF.

But I am getting the error in application staging

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

It actually doesn't consider it as a docker deployment. Rather it considers it as a normal application deployment and searches for the buildpack.

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

Are there any sample pipelines where a docker image which is in a secured registry, is being pushed to CloudFoundry?

1

1 Answers

0
votes

I have gone through the Cloud Foundry Plugin Release Notes (till version 2.3.1), and I do not find any feature where a docker image can be pushed to the Cloud Foundry.

So, I found the below code snippet as a workaround, where the CF CLI has been used to push a docker image, instead of using the Cloud Foundry Plugin.

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'
    }
}