Feedback Loop 1
Based on our overall architecture, the first feedback loop does the following:
- Checkout code
- Apply (any) configuration
- Compile
- Run unit tests (if any)
- Package and upload
- Trigger Code Quality Analysis
Jenkins Job1 Configuration
Below is how a Jenkins Job is configured for the first feedback loop (It is assumed that you have the necessary plugins needed for the job. If you do not, you can install them very easily from the System Configuration section for Jenkins)
Name the Jenkins job, define log rotation strategy
A boolean flag to turn uploading build artifact to Nexus. Default value is OFF
Nexus credentials to interact with Nexus
Pull source code from github
Delete workspace and mask passwords
Set nexus password here, so that it can be masked
Set JAVA_HOME, ANDROID_HOME, GRADLE_HOME and build the project. If any unit tests are written, execute that as next build step. In this case, there are no unit tests (Note: SONAR_RUNNER in this job is redundant, we use sonar in a downstream jenkins job)
Upload the build artifact i.e. app-debug.apk to Nexus, so that it can be used further.. We do not version this artifact with Jenkins build number, because this is snapshot. However feel free to name the artifact aligned with your versioning strategy.
Kick off the downstream job to trigger sonarqube analysis, which is feedback loop 2. The UPSTREAM_BUILD_NUMBER strategy is to pass the value to downstream job to pull the "correct" nexus build artifact.
Finally save the job
Feeback
The console output looks as below