We are trying to build pipeline for docker image using jenkins and cloud build. Jenkins will checkout source code from bit bucket, does soanrqube code analysis, builds artiafcts using maven and pushes to nexus artifactory. Once all these steps are completed successfully next step is to trigger google cloud build which will build the docker image by downloading the artifact from nexus artifactory and pushes the image to GCR.
We have a challenge here. In the maven build step we aare storing the version of the artifact from pom.xml to a variable say VERSION. The same value has be passed to cloud build as value substitution. But the value is not passed from maven build step to cloud build step. Below is cloud build code
- steps:
- name: gcr.io/cloud-builders/gsutil
args: ['cp', 'gs://test-docker-sai/Dockerfile.txt', 'Dockerfile']
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/test-image:$_TAG', '.' ]
substitutions:
_TAG=$VERSION
images: - 'gcr.io/$PROJECT_ID/test-image:$_TAG'
Below is the error from cloud build
Step #1: invalid argument "gcr.io/abcd-ef-ghi/test-image:$VERSION" for "-t, --tag" flag: invalid reference format