I have the same problem as in:
Jenkins multibranch - how to scan branches where jenkinsfile is placed on a submodule?
Note that both repositories are placed on a private gitlab server and they are set as private. However i've no problem in checkout both interdependently on Jenkins.
I have my jenkinsfile for a branch placed on a submodule like so:
main/
...
submodule/ -> submodule
jenkinsfile
But i'm unable to run a Multibranch pipeline. The scan cannot detect the jenkinfile:
Checking branches...
Checking branch main
‘submodule/jenkinsfile’ not found
Does not meet criteria
Processed 1 branches
I've tried all the options on the following thread: Git submodules not updating in Jenkins build
But none work.
Versions:
jenkins version: Jenkins 2.332.3
Git plugin Version 4.11.5 GitHub
Branch Source Plugin Version 1677.v731f745ea_0cf
As anyone figure out the solution to this?
Thanks
I've managed to resolve my issues based on this thread: https://devops.stackexchange.com/questions/9243/is-there-a-way-to-use-a-jenkinsfile-from-a-git-submodule-in-a-multibranch-pipeli
i've installed this plugin: https://plugins.jenkins.io/remote-file/ and it solved my issues.
Related
I have a freestyle Jenkins job with multiple git repositories.
I want Jenkins to ignore one of the repositories when generating the changelog for the build (such as for sending out emails or updating relevant Jira issues).
Is it possible to exclude one of the repositories from the changelog?
I ended up working around this problem myself by removing the the repository from the SCM section of my Jenkins job and writing a script to clone and checkout the repository as a build step.
I want a jenkins job with multiple GIT projects. I want to select a particular GIT project and based on that I should be able to select the branch(similar to GIT plugin) to build.
Any plugins or other solutions to solve this?
There is no direct plugin solution for this. Previously we can do it using Multiple SCMs Plugin. But as of now, only one solution is using pipeline scripting, because that plugin is deprecated.
So, now you can do that by Jenkins Pipeline Scripts. You can see This post for further pipeline multi git scripting.
I solved this by adding a shell command (as a build step) that does an "old fashioned" git clone:
git clone https://$bitbucketUsername:$bitbucketPassword#<yourBitbucketServer>.com/scm/projectname/reponame1.git
git clone https://$bitbucketUsername:$bitbucketPassword#<yourBitbucketServer>.com/scm/projectname/reponame2.git
We are using jenkins for manual triggered jobs to deploy some code.
Jenkinsfile describing our pipeline is located in a jenkinsfile dedicated repo (not in deployed code repo).
We are using declarative pipeline syntax and shared libraries in our jenkinsfiles.
In BlueOcean interface there are 2 interesting attributes (branch and commit) automatically filled when using plugins to trigger pipelines (like github organization).
I'm searching a way to set/update these 2 attributes manually from within the pipeline code for our manual pipelines.
Job description and name can be easily updated using something like :
stage('Set pipeline description'){
steps {
script {
currentBuild.description = "Deploying branch ${branch} on ${targetEnv}"
}
}
}
But I didn't find anywhere how to update branch or commit values.
Did anybody try this ?
This issue is reported as bug (see link).
"We are using GitLab web hooks to trigger Jenkins Pipeline project builds on new commit push to GitLab. Build is triggered, CI commit status report is being sent back to gitlab, but can't see branch and commit field in Header-details element."
Please vote on this issue on Jenkins CI website if you want for the issue to be resolved sooner.
I have a Jenkins Pipeline setup, and a Jenkins file which has the below content:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Hey'
}
}
}
}
A post commit hook triggers the Jenkins build successfully, and I can see it starting from the Jenkins UI. It states that it is checking out the repo to read from the Jenkins file and it stores the checkout in the workspace#script folder on the server.
Checking out svn https://<svn_server>/svn/Test/Core into C:\Program Files (x86)\Jenkins\jobs\CI_Build\workspace#script to read JenkinsPipeline/Jenkinsfile
Checking out a fresh workspace because C:\Program Files (x86)\Jenkins\jobs\CI_Build\workspace#script doesn't exist
Cleaning local Directory .
After this is complete, I make a change to a file in the repo and the build triggers via the post commit hook happily, but then it tries to checkout the entire code base again into a folder called workspace. I would have expected that the checkout happens once and then the "use SVN update as much as possible" option would kick in and only update the changed files? Or maybe I have the wrong logic?
SVN version - 1.9.7
Jenkins version - 2.84
Jenkins has to know what is in your pipeline script before it knows if it should checkout your code. It is possible that your pipeline says not to check out the code, and you set into a subdirectory and fire off the checkout yourself. Or maybe checkout multiple repos in different places. Until Jenkins sees your Jenkinsfile, it can't know what you want. So it has to checkout the repo once to see your pipeline, then again to do the work.
With git (and maybe some versions of other repo plugins) lightweight or sparse checkouts are supported, so then it only grabs the jenkinsfile instead of the entire repo. I don't think this is a supported option in SVN yet.
Lightweight checkouts are now supported by the SVN plugin, the SVN plugin was updated in version 2.12.0 to add this feature - see https://wiki.jenkins.io/display/JENKINS/Subversion+Plugin.
I'm using the Bitbucket Branch Source Plugin to automatically configure multibranch pipeline jobs for every repo under a specific project directory within Bitbucket. One repo contains a valid Jenkinsfile. The master branch for that repo builds and deploys fine. However, pull requests for that repo are not being built. I see the following logs:
Connecting to <URL> using <credentials>
Looking up repositories of team <Project>
Proposing test-project
Connecting to <URL> using <credentials>
Looking up <Project>/test-project for branches
Checking branch master from <Project>/test-project
Met criteria
Looking up <Project>/test-project for pull requests
Checking PR from ~<user>/test-project and branch feature/thing
Does not meet criteria
The specified branch for the pull request does contain a Jenkinsfile, so I do not understand why it says that the criteria are not met. Any suggestions?
The "Automatic branch project triggering" option is set to the default .*
I'm using the following plugins to Jenkins:
Bitbucket Branch Source Plugin 1.8
Branch API Plugin 1.10.2
GIT Plugin: 2.4.0
Pipeline 2.4
Pipeline: Multibranch 2.8
Pipeline: SCM Step 2.2
SCM API Plugin 1.3
... others omitted for brevity
Well, I feel dumb.
Jenkins did not have read permission on <user>'s fork of the repo containing the branch for the PR.
When you make a PR, all the users with access to the repository receiving the PR are able to view it without issue, so this may be an issue with Bitbucket Server itself (I'm on 4.2.0) not allowing those users to have remote read access to that branch once it has been included in a PR.