Can Jenkins used with python project? - jenkins

I'm developing a web application using python django. I want a CI service which can automatically pull the latest code from my github and run some test then deploy. I'm not familiar with CI, after searching for a while I found Jenkins seems to be a good solution. Can Jenkins be used for this?

Jenkins can be used with any project.
Regarding pulling the latest code, add the Jenkins GitHub plugin in order to be able to check "Build when a change is pushed to GitHub" under "Build Triggers".
That will launch your job on any new pushed commit on the GitHub repo.
From there, a Jenkins job can execute any command that you would do in command-line, provided the agent on which said job will be scheduled and executed has the necessary tools in its PATH (here python)
An alternative (which does not involved Jenkins) is to setup a webhook and a listener on your server which will detect a "push event" sent by said webhook.

Related

Run Test automation code from Development repository on every push through Bitbucket pipelines

I am Test automation engineer and I have developed my automation code repository to test functional aspect of the product. I want this code to run when any developer pushes feature or bug on the beta environment.
I have built the pipeline on Automation repository, and I am using docker image for selenium and maven for the same. When I push any changes on my repository pipeline triggers but I want this same to happen from different repositories.
One solution I can think of it is Trigger automation pipeline from developer's pipeline through REST API (pipeline-initiated). But this is not a full proof solution as automation pipeline image will not be updated after the changes made by developers.
In short: We have automation tests written in one repo and development code run into one repo. As a part of CI/CD/CT, I want all of these things run automatically and we get the bug free build every time.
You should try Ansible for this scenario. As you already have you docker images . Just wrap it with ansible and use to to trigger automation on different repos push trigger.

Trigger a new build via Codeship API from Jenkins

I have a CI/CD setup with a Jenkins server to manage our internal CI/CD. We have Codeship performing our CI/CD for our AWS work.
I'm looking to setup jobs on our Jenkins server to manage when new builds are triggered on Codeship.
The aim being, we will have our Jira dashboard integrated with Jenkins in such a way that as an issue's status changes, specific jobs are executed.
So I'm trying to create a job that uses Codeship's API to trigger a new build, but it appears that you can only rerun an old build? How do you trigger a fresh build?
From the docs enter link description here you can only retrieve information and restart previous builds.
You want to run specific jobs, but those must be associated with some specific commit on your repository. You can identify the build for that specific commit and restart it.
Builds are always triggered from your git repository (github or bitbucket), and Codeship is highly dependent on that to keep the flow as simple as possible. You don't need to upload anything anywhere and then command Codeship to run a build on that. All you need is specify a repository and push something.
You could create an internal git server where your developers push to and with jenkins you can push changes from there to a repository connected to Codeship. That way you could control indirectly what gets tested and what does not.

CI and CD implementation issues

I am looking for implementation of CI/CD in to my current project here is what i think will work.
Environment consists of
- Jenkins
- git
- docker
- gradle
- Linux servers
- Sonar
- Ansible.
Each tool will be used as following.
Git:- Developers will push there code to this CVS.
Jenkins:- On detecting Check-in Jenkins will trigger a build and will deploy to one of the server.
Sonar:- will be used for code coverage and will check the code before building the same through Jenkins.
ansible:- ansible will be used to quickly prepare added nodes so that code can be deployed to them.
Docker in case if we need fresh test environments every time we can use docker+ ansible combo for doing the things.
Flow of work will be
User run unit test cases on his machine and commits the code to the server.
Jenkins will pull the code from git and will run sonar on the same and will generate reports.
jenkins will create build and will deploy the same on dev server.
A jenkins job will run and will perform the integration testing on the dev server
Any other automated tests can be run.
Finally builds pushed to next server using Jenkins.
I will use shell commands inside Jenkins to push compiled code from one server to another.
In my this scenario can some one answer me following.
Where will sonar get fit and how to use the same?
I see there are CD tools, cant i push compiled code to the servers using shell scripts written inside the Jenkins jobs to automatically deploy the things? What extra benefits a CD tool provides
Is is wise to create fresh test environment or we can keep using the old one again and again?
Will this complete CI/CD?
can someone share there implementation
You say you plan to use Git. I'll outline a scenario using Git on GitHub
Developers push code changes here as pull requests
The SonarQube GitHub Plugin kicks off an initial analysis of only the code changed in the PR looking for the introduction of new issues (note that coverage and duplications are not included in this check)
Once the PR is merged, Jenkins (in one job or several, depending on your needs)
builds
fires integration tests & any other automated tests
runs SonarQube Scan. Note that this comes last to include integration test results.
pushes build to next server
Note that the ability to break the build when the project doesn't pass the SonarQube Quality Gate you've set up may be desirable in your situation. Unfortunately, it's not available in the current server version: 5.2. It is available in 5.1, and is should return soon.

Gitlab and Jenkins integration novice

What do you put into the system hook URL? I see a lot of examples but they look like JSON scripts to me.
I'm trying to configure gitlab to hook jenkins to create projects when projects are generated in gitlab. I'd also like builds to be run when a merge (pull) request is generated for a repo.
I've followed the steps outlined here for the gitlab hook plugin:
http://doc.gitlab.com/ee/integration/jenkins.html
But it's still not generating builds on push requests. Perhaps i don't have something setup right?
I have also tried and failed to configure Gitlab to integrate with Jenkins by following the instructions at http://doc.gitlab.com/ee/integration/jenkins.html#jenkins-service
For me the reason was that I didn't have Gitlab EE installed. The page specifically states: "The Jenkins project service code is only available in GitLab EE"
I discovered by chance my answer. In gitlab under the project settings you can add the following hook to trigger a build on a pull request or commit.
http://gitlab.example.com/job/example_project/build?token=UserToken.
I believe I saw it in Jenkins.
Now i've installed the gitlab plugin and i've tried the build_commit? hook and some other hooks but i was running into other errors such as asking for repo location when i've provided it. This does the trick though and i'm happy enough for now.

Github Jenkins plugin with Github Enterprise

I have a Jenkins server with the following github plugins:
github-api
github
github-pull-request
I want to trigger a build after a merge (from a PR). This is because I have some build chains that I don't execute when building a PR so after a merge I need to create new deployment packages.
In the enterprise github there doesn't seem to be the same interface (as regular github) for webhooks I don't seem to be able define what events the github plugin (webhook) should listen for so I think its just the default 'push' event. Is this done somewhere else or is it a limitation of the enterprise version?
UPDATE
I have the github plugin working now but its builds for every push if I check the box. This disucssion https://groups.google.com/forum/#!topic/jenkinsci-users/gew5gWVDxw8 suggests that I should be able to use the git scm and github plugin together. Github plugin will register a change, scm plugin will poll server to determine if this change was tho the watched branch. I also tried this suggestion How can I make Jenkins CI with git trigger on pushes to master?
When I try and configure this no branch is ever built!
At least for me it's not exactly clear from your question what you actually exactly want.
It sounds like you only want builds to be triggered if there are some new commits on github on a specific branch.
If this is all you're looking for, you can just setup a webhook (Jenkins (Github Plugin)).
In you Jenkins job, just specify the branch you're tracking (Branches to build).
Assuming you setup github's hoock to jenkins correctly, this should trigger your build job on each commit on github enterprise.
If your hook doesn't seem to work: To check if and what your github server actually would send to your jenkins server, you can temporarily replace the url to your jenkins server in github's webhook with something like requestb.in (this will let you inspect github's hook payload)

Resources