A Deep Dive Into Continuous Integration Using Jenkins Pipeline
Sauce AI for Test Authoring: Move from intent to performance in minutes.|xBack to ResourcesBlogPosted<
Sauce AI for Test Authoring: Move from intent to performance in minutes.
|
x
Blog
A Deep Dive Into Continuous Integration Using Jenkins Pipeline
Jenkinsis an open-source continuous integration (CI) puppet that helps orchestrate the ontogeny processes (build, test, and deployment) with automation. The CI line offers many ways to create the automated line, from freestyle project to the first-class plugin called Pipeline. You can quickly progress out an end-to-end CI resolution by evolve and loading pipeline playscript from the source control manager (SCM). This approach increases confidence in what gets delivered by providing various style to control flow elements (defining approval, manual, or automated).
Getting Started
In a nutshell, you require to install theJenkins Pipeline plugin. I also urge installing the following two Jenkins plugins along with the Pipeline plugin: thePipeline Stage View and Multi-branch Pipeline. If you take more information on how to set up Jenkins, mention my & quot;Getting Started Guide for Setting Up Jenkins& quot; blog post.
There are two attack to creating pipelines: You can write the pipeline script either within the Jenkins UI or through a container file. This article will only focus on developing and loading aJenkinsfilecontainer file into Jenkins.
Develop the Pipeline Scripts
Jenkins is useful because it orchestrates freestyle line into a CI pipeline. On its own, the freestyle job coming is clunky and hard to negociate for large-scale projects. However, the Pipeline scheme simplifies the chained CI pipeline by creating one Jenkins job that reads a container file. The Jenkinsfile is a container file that orchestrates your CI grapevine by running different phase as needed. The container file point what specific steps are required to execute a job, or multiple line you want to use.
Let & # x27; s interrupt down some terminology, so examine a Jenkinsfile codification snip.
Terminology:
Node:This selects where the grapevine will be action. The node is oftentimes a remote machine, but it can be the local master as well. To throttle where this pace or pipeline executes, you can use the optional label to select where to run it on.
Stageenables you to define a set of machine-driven tasks. Each phase activity can hold one or more build steps within it. I recommend working within the stage since it helps organize check, commit, and acceptance divisions within the CI grapevine.
For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.
Code Snippet - Jenkinsfile
node (& # x27; slave-node-01 & # x27;) {
level & # x27; Checkout & # x27;
checkout scm
sh & # x27; pipeline/prepare-gems.sh
stage & # x27; Commit & # x27;
parallel & # x27; Static Analysis and Local Testing & # x27;: {
sh & # x27; pipeline/run-static-analysis.sh & # x27;
sh & # x27; pipeline/run-unit-tests.sh & # x27;
}
stage & # x27; Acceptance & # x27;
sh & # x27; launch-environment-acceptance.sh & # x27;
parallel & # x27; Acceptance Testing & # x27;: {
sh & # x27; run-infrastructure-tests.sh & # x27;
sh & # x27; run-selenium-tests.sh & # x27;
}
Create individual scaffolding book to indite the continuous integration pipeline. Here is a sampling cuticle book for running Selenium tests as component of the Acceptance phase.
run-selenium-tests.sh
SELELIUM=true
REMOTE=true
SAUCE_CONNECT_LOC= & quot; /home/jenkins/sc-4.3.16-linux/bin/sc & quot;
cat - & lt; .rspec
--color
-- format html
-- out rspec_results.html
END
bundle listing
rake test_sauce
Load the Pipeline
Once you have finished developing your CI pipeline with a simple container file that uses the Pipeline plugin DSL (domain-specific language), via the Jenkinsfile to import several shell scripts, you & # x27; re ready to make a Jenkins CI pipeline by loading your Jenkinsfile into Jenkins.
Let & # x27; s start by setting up a new Jenkins job and selecting the Multibranch Pipeline project. Remember earlier that I commend using the Multibranch Pipeline plugin, since it create a set of grapevine undertaking according to detect branches in the defined SCM repository. The constellation is super uncomplicated - it only ask occupy out branch source and configuration fashion.
Let ’ s Trigger the Pipeline Execution
I recommend employGithub webhooks over Poll SCM. The webhooks allow Jenkins to trigger jobs automatically after the creation of a fuse pull request (PR). To enable Github webhooks, you must install theGithub Pull Request Builderplugin and follow the configuration instructions.
Multibranch Pipeline View
Branch Stage View
Conclusion
This Jenkins CI access allows you to chain several stages together via playscript rather than manually make multiple jobs and chaining them together. I love how it simplifies the orchestration of the pipeline point (build, tryout, and deployment) with automation.
In this clause, we ’ ve review which Jenkins plugins are necessitate for the Jenkins CI approaching, and how to get start with scripting, pipeline loading, and triggering the line. If you ’ re interested in learning more about this approach and scripting your next CI pipeline, check out thisPipeline Steps Referencedocument. Start tomorrow by removing the cluttered freestyle jobs from your CI pipeline.
Greg Sypolt (@ gregsypolt) is a aged engineer at Gannett and co-founder of Quality Element. He is a passionate automation engineer seeking to optimise software development character, while coaching team members on how to write great automation playscript and helping the test community become better testers. Greg has expend most of his career working on package calibre - concentrating on web browsers, APIs, and mobile. For the past five years, he has focused on the conception and deployment of automated tryout strategies, frameworks, instrument and platforms.
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free