jenkins-pipeline

Conditional environment variables in Jenkins Declarative Pipeline

此生再无相见时 提交于 2020-01-23 05:01:07
问题 I'm trying to get a declarative pipeline that looks like this: pipeline { environment { ENV1 = 'default' ENV2 = 'default also' } } The catch is, I'd like to be able to override the values of ENV1 or ENV2 based on an arbitrary condition. My current need is just to base it off the branch but I could imagine more complicated conditions. Is there any sane way to implement this? I've seen some examples online that do something like: stages { stage('Set environment') { steps { script { ENV1 = 'new1

How do you pull git committer information for Jenkins pipeline

若如初见. 提交于 2020-01-22 20:13:05
问题 I have a pipeline set up in groovy and need to pull the person who committed some code in git so I can publish that persons name who broke the build. I've searched the web and can't seem to find a solution. I figured out how to publish posted in slack by using the slack plugin for jenkins. Example: slackSend color: 'warning', message: "${git.user_name} broke the build." 回答1: You have to use shell for that and execute git command to retrieve data, store it in a file and later read the file

How to use source command within Jenkins pipeline script

笑着哭i 提交于 2020-01-22 13:37:05
问题 I recently rewrite bash execution command into Jenkins pipeline. The old code is like ... source environment.sh //Build //Test ... Now I use pipeline script to wrap the command, like this sh ''' ... source environment.sh //Build //Test ... ''' However, I got an error, as .../.jenkins/script.sh: line 9: source: environment.sh: file not found . When I try to less environment.sh , it display correctly. So I suspect something wrong with source command within sh wrap . Before using pipeline,

Jenkins pipeline job: Set sleep time from a string parameter?

混江龙づ霸主 提交于 2020-01-22 10:29:07
问题 I'm new to Jenkins Pipeline jobs, and I'm facing an issue I cannot solve. I have a stage with a hardcoded sleep seconds value: stage ("wait_prior_starting_smoke_testing") { echo 'Waiting 5 minutes for deployment to complete prior starting smoke testing' sleep 300 // seconds } But I would like to provide the time argument via a job (string) parameter SLEEP_TIME_IN_SECONDS . But whatever I have tried, I am not able to get it to work. How do you convert a string parameter to the int time

no such DSL method `stages`

僤鯓⒐⒋嵵緔 提交于 2020-01-22 04:35:12
问题 I'm trying to create my first Groovy script for Jenkins: After looking here https://jenkins.io/doc/book/pipeline/, I created this: node { stages { stage('HelloWorld') { echo 'Hello World' } stage('git clone') { git clone "ssh://git@mywebsite.com/myrepo.git" } } } However, I'm getting: java.lang.NoSuchMethodError: No such DSL method "stages" found among steps What am I missing? Also, how can I pass my credentials to the Git Repository without writing the password in plain text? 回答1: You are

Get failure reason from Jenkins pipeline

荒凉一梦 提交于 2020-01-21 06:55:10
问题 I'm setting up a declarative pipeline for Jenkins. In my post section, I am using slackSend to notify my team that the build is broken. I'd like to include the failure reason. Is this available in env or currentBuild or something else? I haven't seen anything in the documentation, but seems like a common use case I've seen some posts about using currentBuild.rawBuild.getLog(10) and that works, but it is just filled with way too much information. I need to zero in on the actual exception 回答1:

Get failure reason from Jenkins pipeline

牧云@^-^@ 提交于 2020-01-21 06:55:05
问题 I'm setting up a declarative pipeline for Jenkins. In my post section, I am using slackSend to notify my team that the build is broken. I'd like to include the failure reason. Is this available in env or currentBuild or something else? I haven't seen anything in the documentation, but seems like a common use case I've seen some posts about using currentBuild.rawBuild.getLog(10) and that works, but it is just filled with way too much information. I need to zero in on the actual exception 回答1:

Share gitlab-ci.yml between projects

不想你离开。 提交于 2020-01-20 19:55:37
问题 We are thinking to move our ci from jenkins to gitlab. We have several projects that have the same build workflow. Right now we use a shared library where the pipelines are defined and the jenkinsfile inside the project only calls a method defined in the shared library defining the actual pipeline. So changes only have to be made at a single point affecting several projects. I am wondering if the same is possible with gitlab ci? As far as i have found out it is not possible to define the

Cannot start Jenkins server

≯℡__Kan透↙ 提交于 2020-01-17 03:10:11
问题 Cannot start jenkins. giving below logs when try to restart but doesnt work - -bash-3.2$ ./jenkins.sh start Jenkins is currently stopped... Starting Jenkins with command cd /eas/jenkins;/eas/jenkins/jenkins_jre/jre1.7.0_51/bin/java -Xms1024m -Xmx2048m - XX:MaxPermSize=512m -DJENKINS_HOME=/eas/jenkins/home -jar jenkins.war -bash-3.2$ standard in must be a tty Please help! 回答1: No, adding to sudoers file didnt solve it. there was issue with JVM where JDK was not able to initialize because of

Multi-Module local jar dependencies - Jenkins Pipeline

谁都会走 提交于 2020-01-16 14:53:43
问题 I need to build a Java project on Maven. I am working on a multi-module Maven project that's built on the Jenkins Pipeline in the Nexus repository. I have a few libraries that are not available on the Nexus repository. I can't manually upload the libraries. I am building this project on a pipeline. What I did: I created a folder named jars in the project root of the Git hub repository and manually put all the jar files that are not available on Nexus. In the dependency, I referenced all these