Upload/download files to/from Google Storage
Upload and download a JAR from Google Storage from within a pipeline
- A Codefresh account
- A Google Storage Bucket with public read access
- A private key downloaded for the existing service account associated with your bucket (for this example, we base64 encoded the key for ease of use in a pipeline variable using
base64 key_file.json > key_file.b64)
The example project is at GitHub. The application is a simple Scala Hello World application contained in a jar, with a dependency on a scala-library jar which we will download from the bucket and package into a Docker image.
Our project contains two pipelines, one to upload the dependency JAR to our bucket, and the other to download the JAR from the bucket.
Create the first pipeline
The first pipeline contains one stage/step, to upload the JAR to the Google Storage Bucket.
You need to define a pipeline variable, KEY_FILE, in the pipeline settings:
Here is the first pipeline:
- Uploads a JAR from Maven into our Google Storage bucket through a freestyle step.
Create the second pipeline
Our second pipeline has four stages:
- A stage for cloning the repository
- A stage for downloading the jar from the bucket
- A stage for building the image
- A stage for pushing the image to the repository
Here is the YAML for the second pipeline:
This pipeline does the following:
- Clones the source code through a Git clone step.
- Downloads the dependency JAR from our publicly-accessible Google Storage bucket through a freestyle step.
- Builds a docker image through a build step.
- Pushes the Docker image to the DockerHub registry you have integrated with Codefresh through a push step.
CI/CD pipeline examples
Codefresh YAML for pipeline definitions