9

In my automatic jenkins job, launched daily, if there are no changes the git commit command returns 1. That will mark the build as failed. To solve this problem I use these two commands in my shell build step: git add -A git diff-index --quiet HEAD || git commit -m "Jenkins automatic update commit" the first will eventually add all unstaged files in the ...


6

In order to get a success, you need to avoid non-zero exit codes. A simple solution would be to change the last line of your script to git commit -a -m 'Changes pushed by Jenkins' || true, but better solutions would parse the output of git-add and only run git-commit when there is something to commit.


6

No, there still isn't any common practice for this since this is not very common. I would recommend you to create a Development Jenkins Environment and run tests against it. Right now you will have to do that from scratch since there are not many open source repositories that could help you. So, how does this Jenkins Development Environment look like? For ...


3

You need to use double quotes instead of single quotes. Single-quoted strings don't perform string interpolation. For instance: parameters { string( name: 'DEPLOY_BUILD_NUMBER', defaultValue: "${BUILD_NUMBER}", description: 'Fresh Build and Deploy OR Deploy Previous Build Number' ) }


3

One could also use docker Jenkins LTS. If one wants to start from scratch, just remove the mounted Jenkins home folder and there will be a clean Jenkins in no time. https://github.com/jenkinsci/docker/blob/master/README.md


3

I've done this before. Essentially you can use the Jenkins CLI to import/export jobs, which will allow you to create and/or update a job with the definition you want to run. Be it JenkinsFile or some groovy script or whatever. Check this blog for details. Once you (re)define the job, you will simply remotely execute it using the same Jenkins CLI. You can ...


2

I assume you would like to run locally to test logic? If so there is a unit testing framework for Jenkins declarative / scripted pipeline. I have not personally used it but this would enable me to test stubbed logic locally. Alternatively, as you're no ta fan of GUIs you could have a look at Jenkins X which has a very powerful CLI and is more gitops driven.


2

I find it strange that nobody mentioned the Configuration as Code plugin. Our solution to this problem is to maintain a base Docker image for jenkins, provisioned with two config files: jenkins.yml plugins.txt The plugins are installed by the install-plugins.sh script provided by the base Jenkins image: COPY casc_configs/plugins.txt /usr/share/jenkins/ref/...


2

I'm going to assume that you have a way to know if the commit is empty or not. You can use the following code to mark the job as a success instead of relying on error codes. if( some use case ) { currentBuild.result = 'SUCCESS' echo "Job succeeded." return } You have two options for placement. Putting this inside a stage will exit only that ...


2

One possible approach, although a bit tedious (and a bit dumb), would be to: make a fresh Jenkins installation of the exact same version on another (maybe scrappable) machine get the list of the (default) plugins it ends up with add/remove/update the plugins in the original Jenkins installation to match that list


2

One could use ansible geerlingguy.jenkins role. When this role is applied, a Jenkins system will be created without any plugins. Subsequently, one could install plugins manually, but also define them in ansible, i.e. plugins as code.


2

It looks like there exists a plugin to do exactly what you want: Display console output plugin. However, I haven't tried this plugin myself, and it looks like this plugin is not well-maintained, so I cannot vouch for the quality of this plugin.


1

I'm not very familiar with Jenkins on Windows, but I imagine your issue lies in the fact installing Jenkins on drives other than C:\ are more difficult to deal with. Since Jenkins is not running, you'll have to configure config.xml by hand. Here's a post on stackoverflow.com that may help you. As they state, you'll probably need to find the Workspace Root ...


1

How Do I Restrict Access to Agents (previously called Slaves)? You haven't specified what Jenkins you're running or whether you have licensed Cloudbees plugins. If you have the Cloudbees folder plugin together with the Cloudbees Folders Plus plugin, there is a "simple" way to do what you ask. To take advantage of the power of the folder and folder ...


1

You could use Project-based Matrix Authorization Strategy for user authorisation in Jenkins. Works well with Folders plugin, then you have each project in a separate folder and permissions on each folder are set to a team that looks after the project. Each node/slave can have access permissions specified. For example, for node A you will only list Team A as ...


1

As far as I can tell, there is no native functionality in Active Choice Parameters to load the Active Choice code from SCM. There are a couple ways to build this functionality yourself, however they're both clunky solutions that can be difficult to debug. (Unfortunately I can't copy any example code from my work right now because I'm at home on my personal ...


1

This is similar to: https://stackoverflow.com/questions/55023570/how-to-run-a-job-on-first-available-node/55567958 Have you considered Least Load plugin? https://plugins.jenkins.io/leastload By default Jenkins tries to allocate a jobs to the last node is was executed on. This can result in nodes being left idle while other nodes are overloaded. This ...


1

I would recommend against importing if at all possible. You can use built-in functionality to achieve the same results. Also be aware of "In-process Script Approval" https://stackoverflow.com/a/42662243/1678094 // GET def get = new URL("https://httpbin.org/get").openConnection(); def getRC = get.getResponseCode(); println(getRC); if(getRC.equals(200)) { ...


1

You have two arguments that are empty: <application-desc main-class="hudson.remoting.jnlp.Main"> <argument>32ba31ca5f150c2b3491802b0b60e56574d970a9e601cebad656a113fe325a85</argument> <argument>FQDNofWindowsSlave</argument> <argument>-workDir</argument> <argument/> <argument>-internalDir</...


1

Sounds like the docker image you are using doesn't have the correct name, or is stored in a private repository which requires login. Please post more information


Only top voted, non community-wiki answers of a minimum length are eligible