Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

You can also use error to exit the current stage, then you don't have to consider the current stage hierarchy and similar stuff: def autoCancelled = false try { stage('checkout') { ... if (your condition) { autoCancelled = true error('Aborting the build.') } } } catch (e) { if (autoCancelled) { currentBuild.result = '...


5

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.


4

I had a similar situation in which I wanted to nest other parallel jobs threads inside another parallel one. This code worked for me: def performDeploymentStages(String node, String app) { stage("build") { echo "Building the app [${app}] on node [${node}]" } stage("deploy") { echo "Deploying the app ${app}] on node [${node}]" ...


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

I believe it is now possible to configure the webhook on per-repo basis: https://mohamicorp.atlassian.net/wiki/spaces/DOC/pages/381419546/Configuring+Webhook+To+Jenkins+for+Bitbucket+Bitbucket+Branch+Source+Plugin


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

buildEnv.inside("-u 0") {} resolved my problem. But then the workspace will contains directory and files owned by root which can not be deleted by the user Jenkins at the next run when cleaning the workpace , so I have added sh "sudo chown jenkins: -R \$PWD/" at the beginning of the pipeline.


3

I just had a similar issue today, although with another image. docker { image 'node:8' args '--tmpfs /.config' } Reference: https://docs.docker.com/storage/tmpfs/ This way you shouldn't be worried about any security leaks or files which are present after the container is destroyed inside the jenkins.


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

Specifically for credentials, CloudBees recommends using the Credentials Plugins, which inject the credentials in the environment available to the invoked scripts. From Injecting Secrets into Jenkins Build Jobs: Credentials plugin - provides a centralized way to define credentials that can be used by your Jenkins instance, plugins and build jobs. ...


3

If you are using Pipeline (i.e. Jenkinsfile), use withCredentials. To give a quick and dirty example: withCredentials([[ $class: 'UsernamePasswordMultiBinding', credentialsId: 'my-credentials', usernameVariable: 'user', passwordVariable: 'pw', ]]) { sh("./my-python-script.py --user ${user} --password ${pw}") } Your credentials will be ...


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

Looks like you are using the Gitlab plugin for jenkins? if so this link should be of help https://github.com/jenkinsci/gitlab-plugin#declarative-pipeline-jobs


3

You are running into a conflict between jenkins nature of making sure everything is done before a job is complete and your desire for some long-running things to be asynchronous. There is no right answer here, both are reasonable desires, but you and jenkins are pulling in different directions. It may be ok for some parts of the jenkins job to not be ...


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

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:


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

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

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

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

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

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


2

what you are looking for is compliance and security for containers. There are companies that can do this out the box for you, and even though I'm not advocating for either you can see what they offer and use that as a template. https://www.twistlock.com/platform/container-compliance/ https://www.aquasec.com/use-cases/container-auditing-compliance/ As a ...


2

Apparently this was caused by the pipeline name having an apostrophe character in it. Renaming the build solved the issue.


2

Depending on how long you keep builds for, the Rebuild option in the left hand sidebar will allow you rebuild a previous run of the job with the parameters intact. Simply find a previous build of the job that that particular user kicked off last time, click into it, then choose Rebuild from the sidebar. Again this will only work if Jenkins keeps enough ...


2

Jenkins Job and Jenkins Pipeline are basically the same. In a pipeline you define the steps of your job as groovy code (actually it is CPS https://github.com/jenkinsci/workflow-cps-plugin, but that should in general just be a custom groovy interpreter). The point, that is making pipelines "better", form my perspective, is, that you can add those in so-...


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