A sample app to be deployed on openshift environments
Note: to build this repository with maven you must specify "-Popenshift", eg "mvn clean package -Popenshift"
To trigger a build when a push is made to GitHub, do the following:
-
Create a Pipeline job in Jenkins, with the following config:
-
Tick 'GitHub Project' and set Project URL to:
https://github.com/monodot/jee-ex-jgitflow
- note that Jenkins will add a trailing slash; this is fine. This URL must not end in.git
-
Tick the box labelled 'GitHub hook trigger for GITScm polling'
-
Configure the job with this pipeline:
node { stage('Hello') { git url: 'https://github.com/monodot/jgit-flow-demo.git', branch: "master" } }
-
-
Edit the job (using Configure) and then Save it again. (This seems to be required by the plugin.)
-
Now build the job manually. The job must have run successfully at least once in order for the GitHub trigger to be fired.
-
Now make a commit and push to GitHub. This should trigger the job in Jenkins.
Multibranch jobs in Jenkins allow a job to be created automatically for each branch in the repository. Note that each branch in the remote repository must contain a Jenkinsfile in its root.
-
Create a Multibranch Pipeline job in Jenkins, with the following config:
- Add a Source, choosing Git as the type.
- Specify the Project Repository as:
https://github.com/monodot/jee-ex-jgitflow.git
- Add a Pipeline Library:
- Name:
pipeline-library
- Default version:
master
- Project repo
- Name:
-
In GitHub, go to Settings → Integrations & services and add the Jenkins (Git plugin) integration.
- Set the Jenkins URL to (e.g.)
http://yourjenkins:8080
orhttp://abc123456.ngrok.io
- Set the Jenkins URL to (e.g.)
-
Now whenever you push to GitHub, a job will be triggered in Jenkins for the given branch.
The Jenkinsfile in this repository assumes that Jenkins will be executing builds on maven slave nodes (e.g. using OpenShift/Kubernetes). If using a local instance of Jenkins to test, you will need to define a maven node, so that the pipeline can run:
-
Go to Manage Jenkins → Manage Nodes → New Node.
-
Add a new node with the following properties:
- Name:
maven
- Remote root directory:
/path/to/a/writeable/directory
- Usage: Only build jobs with label expressions matching this node
- Launch method: Launch slave agents via SSH
- Host:
localhost
- Credentials: (add your SSH credentials here)
- Host Key Verification Strategy: Non verifying Verification Strategy
- Name: