Hot answers tagged

11

As you guessed, build not necessarily means "compile". Building is a process of creating software from sources, which might include stuff like gathering dependencies, compiling, archiving, transforming code in any way, but also testing, deploying to different environments and promoting the artifacts between them.


6

No, the credentials will only be visible within the block passed to withCredentials, not outside of that. There is no way to make the credentials globally available without switching to Scripted Pipeline. With Scripted, you can wrap your entire job in withCredentials. This is not possible with Declarative.


5

if you want just access the log and download it as a txt file to your workspace from the job's URL: ${BUILD_URL}/consoleText On Linux, you can use wget to download it to your workspace wget ${BUILD_URL}/consoleText The actual log file on the file system is in the Master machine. You can find it under: $JENKINS_HOME/jobs/$JOB_NAME/builds/...


4

This also works, if you want to stay within the Declarative Pipeline space // declare our vars outside the pipeline def tests = [:] def files pipeline { agent any stages { stage('1') { steps { script { // we've declared the variable, now we give it the values files = ...


4

You can use the "when" block combined with the built in "changeset" condition to conditionally run only certain stages of your monorepo's pipeline. From the when.changeset documentation: changeset- Executes the stage if the build’s SCM changeset contains one or more files matching the given string or glob. Example: when { changeset "**/*.js" } Here is an ...


4

I figured it out by myself, there is no plugin needed. build.sh &> /dev/stdout | tee jenkins.txt and then curl -F file=@jenkins.txt -F channels=yourchannel -H "Authorization: Bearer your token" https://slack.com/api/files.upload There is no '#' needed for slack channel and channel should not be private. And if you use buils.sh | tee jenkins.log ...


4

You need to define variables before the pipeline block starts. Then it should be work. def foo = "foo" pipeline { agent none stages { stage("first") { sh "echo ${foo}" } } }


4

The issue is related to the method used to copy the $JENKINS_HOME from one location to another one. # Logon on the master where you have the issue ssh machine # Shutdown the jenkins master (take care that nothing is running) sudo service jenkins stop # Find all erroneous directories find /opt/jenkins/jobs -type d \( -name "last*Build" -o -name "lastStable"...


3

The JUNIT plugin has a built-in publisher for aggregating test results called "Aggregate Downstream Test Results". You need to make sure that the 'parent' and 'child' jobs are linked together with a downstream/upstream relation. This is usually done by archiving an artifact in the parent build and copying it to the children builds using the 'Archive Artifact'...


3

I'm using scripts from sue445/jenkins-backup-script. It archives Jenkins settings and plugins such as: $JENKINS_HOME/*.xml $JENKINS_HOME/jobs/*/*.xml $JENKINS_HOME/nodes/* $JENKINS_HOME/plugins/*.jpi $JENKINS_HOME/secrets/* $JENKINS_HOME/users/* Usage ./jenkins-backup.sh /path/to/jenkins_home archive.tar.gz # add timestamp suffix ./jenkins-backup.sh /...


3

Jenkins is better Because most users moving on to Jenkins, as well as other adoption metrics indicating clear shift in the userbase. the Hudson team has moved to develop Jenkins. So you can trust our expertise and the the passion to keep pushing the software forward. a large number of plugin authors have chosen to support their plugins on Jenkins. So you ...


3

Here is a short snippet you can just run from the jenkins script console, to dump all of your credentials to plain text. com.cloudbees.plugins.credentials.SystemCredentialsProvider.getInstance().getCredentials().forEach{ it.properties.each { prop, val -> println(prop + ' = "' + val + '"') } println("-----------------------") } A more ...


3

It seems your have not opened your 8080 port in Security Groups in AWS. Steps: Go to AWS console Click Security Group and select the security group that you have assigned to your EC2 instance. Click Edit Inbound Rules Add a Custom TCP Rule and add 8080 in the Port Range. You will now see Jenkins rise from the grave :) i.e. first time installation screen. ...


3

This sounds like a problem for git cherry-pick. If you can separate the user story code from the fix code, by committing them separately, you can cherry pick the relevant commit to merge back into the develop branch. See https://stackoverflow.com/questions/9339429/what-does-cherry-picking-a-commit-with-git-mean


3

The variable must be defined in a script section. pipeline { agent none stages { stage("first") { script { foo = "bar" } sh "echo ${foo}" } } }


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

If the job is a jenkins pipeline, open the failed build and select the Replay option. Otherwise select the Rebuild option. Sample Replay Option: Sample Rebuild Option:


3

Single responsibility principle (SRP) Martin defines a responsibility as a reason to change, and concludes that a class or module should have one, and only one, reason to be changed (i.e. rewritten). As an example, consider a module that compiles and prints a report. Imagine such a module can be changed for two reasons. First, the content of the ...


3

Use the Groovy trim() method. For instance, def myTrimmedParam = params.myParam.trim().


2

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 ...


2

I think your issue is rooted in the server variable not being reusable outside the pre-build stage block. In Jenkins declarative, you can define variables like that using the script { ... } block, but once you leave the stage those variables are inaccessible to other to stages. With the previous suggestions, I'd recommend this: House the artifactory ...


2

It's actually a bad idea to run Docker as root. What you should do instead is add the Jenkins user to the Docker group. sudo usermod -aG docker jenkins. That will avoid opening needless security holes and allow Jenkins to do all that it needs to do with Docker, including running as root inside the containers. I do this regularly with my builds, using this as ...


2

Jenkins slave runs in unix system services of z/OS and can run any script or function from there. We use the Git plugin to pull the source code onto z/OS then you have different choices of how to work with it. You can use IBM Dependency Based Build which is Groovy ported to z/OS plus some extensions to specifically work with native z/OS functions such as ...


2

You can try the thinBackup plugin (even though it is not actively maintained) [if taking a logical backup is all you want] (i.e. most of the config xml files, jobs, nodes etc). The backup size won't be huge.


2

If you want to VPN for a jenkins task you would want to use the OpenConnect plugin as you mentioned. Here are the steps to do that: On linux (debian based) sudo apt-get install openconnect Add the following lines to the bottom of /etc/sudoers (ubuntu configuration) jenkins ALL=NOPASSWD:/usr/sbin/openconnect* jenkins ALL=NOPASSWD:/bin/kill* The you will ...


2

The typical approach is to use a folder per environment that contains identically named files: conf/dev/application.properties conf/test/application.properties conf/uat/application.properties conf/prod/application.properties Then parameterize the @PropertySource to use an environment variable such as "env": @PropertySource("file:${catalina.base}/conf/${...


2

Here's the way I do it: no plugin required, just triggering Jenkins api from gitlab-ci. Gitlab-CI I will assume you have a gitlab-ci runner installed and configured. First, you need to have a .gitlab-ci.yml file in your project having a basic structure such as: stages: - my-jenkins-trigger variables: MY_VARIABLE: "EVERYTHING_IS_AWESOME" my-jenkins-...


2

solutions is: OpenConnect Plugin See here: https://wiki.jenkins.io/display/JENKINS/OpenConnect+Plugin OR also you can use below method: On Linux (Debian based) sudo apt-get install openconnect Add the following lines to the bottom of /etc/sudoers (ubuntu configuration) jenkins ALL=NOPASSWD:/usr/sbin/openconnect* jenkins ALL=NOPASSWD:/bin/kill* Then ...


2

As Tensibai mentioned in the comment - better way is backup you Jenkins instance before an update There are different ways to do this: Plugins Jenkins has a lot of backup plugins, most popular is: PeriodicBackup Plugin - be aware, has status This plugin is up for adoption right now, that means there is can be lack of support thinBackup Plugin - the same ...


2

I still dont see how starting an agent creates a clean image. Expanding on your setup would help us provide better answer. That said, from what I can gather here the following assumption comes to mind : You have agents pre-populated on a VM image. Starting this image will in turn start the agent in which you wish to start the build. So you now have a ...


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