All instructions and resources are in attendees/cicd directory.
|
Note
|
Change IP address to the Docker host where Git server is running. |
-
Enable Docker commands in Jenkins
docker-machine ssh <MACHINE_NAME> "sudo chmod 777 /var/run/docker.sock"
Start all services in detached mode by giving the command:
docker-compose up -d
This shows the output:
Creating git_serverdata... Creating cicd_registry_1... Creating cicd_jenkins_1... Creating cicd_git_dbdata_1... Creating cicd_git_db_1... Creating git...
The exact output will differ as all the images may be downloaded.
-
Configure Gogs server by executing the script:
./install-gogs.sh <DOCKER_HOST_IP> <git_server_PORT>
For example:
./install-gogs.sh 192.168.99.100 3000This brings up the page http://<DOCKER_HOST_IP>:3000/user/sign_up in your default browser.
-
Create an account and login using the credentials
-
Create a new repository
javaee7-docker-workflow(take all defaults) -
In a shell:
git clone https://github.com/arun-gupta/javaee7-docker-workflow cd javaee7-docker-workflow git remote add gogs http://192.168.99.100:3000/arun/javaee7-docker-workflow.git git push gogs master
This workspace is a Java EE sample that has Arquillian tests and can be packaged as a Docker image.
-
Access Jenkins at http://192.168.99.100:8084
-
Create a new workflow and use “Workflow script from SCM”.
-
Use the “Repository URL” as “https://github.com/arun-gupta/javaee7-docker-workflow”; and “Script Path” as “Jenkinsfile”.
-
Start a build
-
Checks out the application workspace from Gogs server
-
Builds the application
-
Runs the test (using
mvn test -Pwildfly-managed) -
Creates a Docker image for the application (
mvn package -Pdocker -DskipTests)