CI/CD demo for building, deploying and testing API proxies
-
Clone this repository;
$ git clone [email protected]:apichick/apigee-ci-cd-demo.git
-
Change to the apigee-ci-cd-demo directory.
$ cd apigee-ci-cd-demo
-
Create a folder called secrets inside the apigee-ci-cd-demo folder.
$ mkdir secrets
-
Generate an SSH key pair. Please do not set any passphrase.
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
-
Create the file below containing your Apigee credentials
$ echo "USERNAME=YOUR-APIGEE-USERNAME\nPASSWORD=YOUR-APIGEE-PASSWORD" > secrets/apigee-credentials
-
Copy the private to secrets folder with the following command:
$ cp PRIVATE-KEY-FILE-PATH secrets/git-private-key
-
Replace APIGEE_ORGANIZATION with the name of your organization in config-files/apigee-settings.xml
$ sed -i .bak "s/APIGEE-ORGANIZATION/YOUR-APIGEE-ORGANIZATION/g" config-files/apigee-settings.xml
-
Run the following command:
$ docker-compose up
-
Load the jenkins home page (http://localhost:8080) in your browser and double-check that everything works properly.
NOTE: We will assume that we have one organization with two environments: test and prod.
-
Create a fork for the following repository in Github:
[email protected]:apichick/book-api-v1.git
-
Add the public key corresponding to the private key used in step 4 of the previous section as a deploy key to your fork.
-
Clone the fork.
-
Create a branch for the prod environment and push it to the remote.
$ git checkout -b prod $ git push origin prod
-
In Jenkins click on the job named job-template and then trigger a build supplying as job name the value book-api-v1, as repository URL the one of your fork and the branches to include separated by spaces, in this case: feature/* master prod. The job-template job is a seed job used to create a multibranch pipeline for the API proxies that we would like to build.
-
Every time a branch is created or updated in the remote a build of the job created in the previous step will be triggered.