gitlab-plugin | A Jenkins plugin for interfacing with GitLab | Plugin library
kandi X-RAY | gitlab-plugin Summary
kandi X-RAY | gitlab-plugin Summary
This plugin allows GitLab to trigger builds in Jenkins when code is committed or merge requests are opened/updated. It can also send build status back to GitLab.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Adds a hook to the GitLab server
- Gets the api token
- Create the actions for the given job
- Get a client for an item
- Handle merge requests
- Updates the commit status of a project
- Gets the open merge requests from a project
- Handles a merge request
- Initializes the stream
- Adds the environment variables for the given run
- Check if the merge request hook is compatible
- Checks if the hooks are equal
- Migrates Git triggers
- Compares two pipelines
- Compares two objects
- Returns true if this push is equal to the given object
- Compares two repositories
- Checks if the project should be build or not
- Commit note hook
- Migrate GitLab connection to Jenkins
- Returns true if the attributes are equal
- Removes the award for the given merge request
- Executes the push hook
- Checks to see if we need to build a project namespace
- Writes the status body to the response
- Write status image
gitlab-plugin Key Features
gitlab-plugin Examples and Code Snippets
Community Discussions
Trending Discussions on gitlab-plugin
QUESTION
Today we are sending build-trigger as notes (eg comments) från gitlab merge-requests to tell jenkins start a pipeline. Since we only had one such task we have been happy enough with just checking if a trigger sent as a note reached our pipeline and then acted on that information.
But, now we would like to add more user-requested tasks and need to inspect the comment for the type of request the user ask for.
From the documentation at https://github.com/jenkinsci/gitlab-plugin there are no variables that carries the information from note-trigger to the pipeline. The note seems to be discarded after the comment-regex-filter in the job-configuration in the gui.
I hope I have missed something. Otherwise we have to fetch all notes for the merge-request from gitlab to the pipeline through a rest-call.
...ANSWER
Answered 2020-Sep-11 at 14:16We are doing this (only difference is we are using Bitbucket). Here is the summary:
- In Jenkins we have written code using (jenkins shared library).
- From within the application pipeline (jenkinsfile) we will make a call to the jenkins shared library method (say commentChecker()) to check the the git commit messages and understand what needs to happen.
- In the shared library code commentChecker() - we will first call the Bitbucket API for the branch and get all the commit messages. In your case I think you should able to call (https://docs.gitlab.com/ee/api/commits.html) api and get the details and parse through the messages.
- Shared library is like a common function and all your projects can all this one function to check the commits, easy to handle and make changes.
QUESTION
I want to publish sonarqube with kubernetes. I did successfully with official packages. But i want to use some plugins old version and some custom plugins. In local with docker-compose files, i created a fly-away container that fills the plugins directory(/opt/sonarqube/extensions/plugins) with plugins. And use that volume with sonarqube container. As a conclusion : Sonarqube extensions volume directory is created (or filled) from different container(do the job and die).
I want to use the same path with kubernetes but couldn't do that. My flyaway container didn't fill the path.
My kubernetes deployments files:
1-) sonar-pvc-extensions.yml
...ANSWER
Answered 2020-May-30 at 20:38Are you sure, you want to use the same directory for container volume mounts and to store the plugins. I believe this is causing a conflict. Can you try changing the volume mount directory (in deployment container spec)?
QUESTION
Have a Jenkins job with build parameter BRANCH
. When job run manually user can choose branch from a list to deploy. List provided by git plugin.
But this job also can be invoked by GitLab hook. In this case parameter will have a default value, because didn't receive any input.
Is there a way to have a parameter BRANCH
with relevant information? With a branch name coming from GitLab hook.
P.S. I think it's possible by set default value to something ${BRANCH_FROM_HOOK ?: default_value}
it will check presence of BRANCH_FROM_HOOK
variable. Need only find a way how to put into BRANCH_FROM_HOOK
variable, value of branch coming from hook. I now that gitlab plugin, who receive a hook, set into gitlab.Branch
value of branch from which hook comes.
UPDATE: What I have done to achieve this:
- Specify git parameter:
gitParameter defaultValue: "${env.gitlabBranch ?: "origin/master"}"
but didn't as gitlabBranch
is not set on the build start step.
Setup job parameters as it suggested on gitlab plugin page here:
- Keep Jenkins Environment Variables
- Keep Jenkins Build Variables
- Override Build Parameters
Added to section "Groovy script":
ANSWER
Answered 2020-Apr-14 at 14:20The answer is use Generic Webhook plugin, not GitLab. And use it's feature map his variables to parameters of job:
If your job is parameterized, and you resolve variables that have the same name as those parameters, then the plugin will populate the parameters when triggering job. That means you can, for example, use the parameters in combination with an SCM plugin, like GIT Plugin, to pick a branch.
End.)
QUESTION
For my repository on GitLab I have a Merge Request Hook configured which triggers a build on a Jenkins CI machine. The hooks works as expected when a merge request is opened.
The webhook is configured with the following triggers:
- URL: https://example.com/project/ExampleApp_merge_requests
- Push events: Enabled
- Merge request events: Enabled
- Enable SSL verification: Off
Lately, when I edit the description of the merge requests then the hook also notifies the CI machine.
Here is an example POST request:
ANSWER
Answered 2019-Apr-02 at 12:25Under triggers (Settings -> integrations) perform the below:
- Enable push events (optional branch name - Branch is created via push events even before MR is possible)
- Enable MR event triggers in your project repo
This URL will be triggered when a merge request is created/updated/merged
In Jenkins Plugin configuration -
- Check "Push Events" (Any commits by way of direct Push or Creation)
- Un-check "Opened Merge Request Events"
- Check "Accepted Merge Request Events" (Any commits by way of Merge Request)
QUESTION
Background: We'd like to lock branch for merging while deploy Jenkins job is running
Question:
Is there way to programmatically lock GitLab branch?
e.g. To set "maintainers_can_push": false" on GitLab protected branch
Checked so far:
- Haven't found any mention of such functionality at GitLab plugin.
- Haven't found anything on GitLab branches API page
ANSWER
Answered 2019-Mar-13 at 14:13At https://docs.gitlab.com/ee/api/branches.html#protect-repository-branch there is a link to the page https://docs.gitlab.com/ee/api/protected_branches.html devoted to API calls for listing protected branches, protect and unprotect them.
To protect a branch call POST /projects/:id/protected_branches
. For example
QUESTION
Actually I'm working on creating software deployment jobs which will deploy my software over Ansible roles. The Ansible roles will be executed over a central Jenkins Server to have a GUI for "everybody" who should be able to execute the software deployment.
My Ansible roles and playbooks and so on have their own ansible.cfg which is different to standard ansible configuration under /etc/ansible/ansible.cfg, also /etc/ansible/ansible.cfg will not be changed because it will be used by different Ansible Tasks which need other options.
Now I'm searching for a way how I can set the path to the ansible.cfg file in the Jenkins job. I've already found the Ansible docu (https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-configuration-settings) but I'm not able to set ANSIBLE_CONFIG in the Jenkins Job and also I don't know the "home" of the Jenkins job.
Does anybody had the same problem and has any solution for that? Maybe by setting env vars in Jenkins Job?
EDIT: I've also tried the way over EnvInject Plugin in Jenkins to set ANSIBLE_CONFIG for the build run. Unfortunately with no solution here. I've tried it in the two ways which are described here: How to set environment variables in Jenkins?
That is my output in Jenkins (also tried it without the " " for the path):
...ANSWER
Answered 2019-Sep-26 at 09:13From the output it looks like you are using shell command to execute ansible-playbook. You can try setting environment variable before ansible-playbook command. Below is the example.
QUESTION
I have Jenkins connected with GitLab, both installed by Helm Chart:
...ANSWER
Answered 2019-Sep-01 at 18:25Make a mistake selecting the freestyle option.
After delete the job and recreated with Pipeline option selected, everything works.
QUESTION
In the project I'm working on, we use GitLab CE along with Jenkins for CI.
Currently we merge changes using Jenkins job by just passing branch name as an input parameter. I want to create a job which takes merge request ID (e.g. 123) and uses GitLab URL API to get info such as e.g. source branch, target branch etc. and then does the rest (build, merge).
I'm a total beginner (both to Jenkins and Groovy) and what I did is just:
...ANSWER
Answered 2019-Jul-26 at 08:34It turned out that it was an authentication issue.
I solved this by providing GitLab API private token in header of a request:
QUESTION
I have the following Dockerfile:
...ANSWER
Answered 2019-May-08 at 11:52Instead of using sudo if you want to run command as root user use USER root
line to switch to root and then execute your commands
QUESTION
I have the following Dockerfile:
...ANSWER
Answered 2019-May-07 at 14:59You're running wget
inside the container, but then trying to COPY
it from the host machine to the container. To copy from one container location to another simply use cp
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gitlab-plugin
For Pipeline jobs, surround your build steps with the gitlabCommitStatus step like this: node() { stage('Checkout') { checkout <your-scm-config> } gitlabCommitStatus { // The result of steps within this block is what will be sent to GitLab sh 'mvn install' } }
Or use the updateGitlabCommitStatus step to use a custom value for updating the commit status. You could use try/catch blocks or other logic to send fine-grained status of the build to GitLab. Valid statuses are defined by GitLab and documented here: https://docs.gitlab.com/ce/api/pipelines.html node() { stage('Checkout') { checkout <your-scm-config> } updateGitlabCommitStatus name: 'build', state: 'pending' // Build steps updateGitlabCommitStatus name: 'build', state: 'success' }
Or you can mark several build stages as pending in GitLab, using the gitlabBuilds step: node() { stage('Checkout') { checkout <your-scm-config> } gitlabBuilds(builds: ["build", "test"]) { stage("build") { gitlabCommitStatus("build") { // your build steps } } stage("test") { gitlabCommitStatus("test") { // your test steps } } } } Note: If you put the gitlabBuilds block inside a node block, it will not trigger until a node is allocated. On a busy system, or one where nodes are allocated on demand, there could be a delay here, and the 'pending' status would not be sent to GitLab right away. If this is a concern, you can move the gitlabBuilds block to wrap the node block, and then the status will be sent when Jenkins starts trying to allocate a node.
You use the "Merge When Pipeline Succeeds" option for Merge Requests in GitLab, and
Your Declarative Pipeline jobs have more than one stage, and
You use a gitlabCommitStatus step in each stage to send status to GitLab...
Add a Flexible publish action
In the Flexible publish section: Add conditional action In the Conditional action section: Set Run? to Never Select Condition for Matrix Aggregation Set Run on Parent? to Always Add GitLab actions as required
In order to build when a new tag is pushed:.
In the GitLab webhook configuration, add 'Tag push events'
In the job configuration under 'Source code management': Select 'Advanced...' and add '+refs/tags/*:refs/remotes/origin/tags/*' as the Refspec You can also use 'Branch Specifier' to specify which tag need to be built (example 'refs/tags/${TAGNAME}')
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page