This is the code required to run the Continusous Swagness talk workshop.
This workshop aims at setting up a basic Software factory from scratch on Clever Cloud. We will deploy Artifactory to manage binaries for our Continous Integration, we will use Github and Clever Cloud for the Continuous Deployment setup and everything will be automated with Jenkins.
Create an account on Clever Cloud using Github login: https://console.clever-cloud.com/
Install Clever Tools, a CLI to use the API: https://www.clever-cloud.com/doc/clever-tools/getting_started/
This project is a documentation website. It's just a single html file that will be served statically. You have to fork it here: https://github.com/ldoguin/api-doc
Now go to the Console, click on Personal space
, Create
, an application
(or just go here: https://console.clever-cloud.com/users/me/applications/new).
From that page you can select your Github Repository, simply type api-doc
in the text box.
Now you need to choose the type of application you want to deploy. Since it's just an HTML file, choose Static
.
The next screen lets you choose the hardware resources, simply click next
.
Then you have to give it a name and a description, you can also click straight on Create
.
Right now you don't need any addon, more on that later. Just click on I don't need any addon
.
The next screen is about configuration and lets you define environment variable. Again you don't need anything in particular. Click on next
.
Now Clever Cloud is working to clone your Github code and deploy it. You should start seeing deployment logs.
Once the deployment is successfull, click on the permlink icon to open your now deployed website :)
Jenkins is available as an addon, so click on Personal space
, Create
, an addon
(or just go here: https://console.clever-cloud.com/users/me/addons/new). Then Select Jenkins, Select the plan S (which is free during this workshop).
You don't need to link it to anything so click next
. Than you can give it a name and click on next
.
Now Clever Cloud is going to do a bunch of stuff. Starting a VM for your Jenkins, making sure it's the latest version available and install some plugins.
This can take some time so for the meantime we can move on to Artifactory.
Artifactory is a JEE server and can be deployed as a WAR.
Make sure you installed clever-tools: https://www.clever-cloud.com/doc/clever-tools/getting_started/
and ran clever login
Clone this repository: https://github.com/ldoguin/clever-artif
It contains the Artifactory OSS war and some install script. Get in that directory and start creating the application with the CLI by running the following commands:
clever create --type java --plan xl Artifactory // Create the clever Cloud application, use plan l to make sure artifactory will have enough RAM
clever addon create fs-bucket --plan s ArtifactoryFS // Create the file system bucket, this is where we write the binaries
clever addon create postgresql-addon --plan s ArtifactoryPG // Create PostgresQL database
clever service link-addon ArtifactoryPG // Link the postgres addon to the application
clever service link-addon ArtifactoryFS // Link the FS addon to the application
clever env set ARTIFACTORY_HOME /app/artifactory/home // Set the configuration for artifactory's home directory
clever env set CC_PRE_RUN_HOOK 'sh clevercloud/configure.sh' // Tell Clever Cloud to run this shell script before running artifactory
clever env set CC_FS_BUCKET /artifactory:`clever env | awk -F = '/BUCKET_HOST/ { print $2}'` // Run this to setup the file system, here we are mounting the fs bucket in the artifactory folder
clever deploy
Now you should see Artifactory logs showing up, it's getting deployed :)
Click on the permlink to access your application. It should say it did not found anything. This is fine, just add artifactory
to the URL. It's the name of the war by default.
You should now see a configuration wizard. Pick an easy password like 'test'. Skip the proxy setup, select the generic and maven repositories.
That's it, you have an artifactory ready to accept connections.
Fork https://github.com/ldoguin/clever-swag
This folder contains the jenkins job to be executed. Most of the magic happens in Jenkinsfile. It must be available on Github so that you can automatically choose it from Jenkins. Now edit the Jenkinsfile
. You need to replace all the ldoguin
URLs by your own. Commit and push your changes.
Go back to your Jenkins addon and click on Open and Login
. Welcome to your brand new Jenkins instance.
Go under Manage Jenkins -> Configure System on that page you should see an artifactory section where you can click on add an artifactory server.
- Use artif as Server ID (just like it's on the Jenkinsfile line 11)
- Copy paste the URL yourapplication.cleverapps.io/artifactory
- use admin as Username
- and the password you setup during the configuration wizard
- Click on Test Connection
Click on Save. Now your Jenkins should be able to deploy stuff in Jenkins.
Go Under Manage Jenkins -> Global Tools Configuration In the Maven section click on Add Maven and use mvn as name (as stated in te Jenkinsfile line 13)
Click on Save
Configure Github credentials for the final GitPush in the pipeline Go under Credentials -> System -> Global Credentials -> Add Credentials Select Username with password (it should be the default proposition) Use your Github username and password use the id defined in the Jenkinsfile line 29 for the ID field Click on OK
MAKE SURE YOU DON"T HAVE 2FA ENABLED FOR GITHUB, yes I know it's bad. If you feel confident and now Jenkins you can configure the credentials part of the Jenkinsfile to use SSH keys instead. It's much better in real live. But we are in workshop life.
Click on Open Blue Ocean Create a new Pipeline Select Github click on Create an access key here Save the token creation Copy paste the token and click on Connect Select your organisation Select the clever-swag repo finish the wizard The Job should be running.
The Jobs will generate a maven project and the online documentation. Than it will deploy the Java project in artifactory and push the new documentation to Github. Giving you Continous Integration and Continuous Deployment.