jenkins-2

Invoke a remote jenkins file from another Jenkinsfile

故事扮演 提交于 2019-12-04 13:57:55
问题 I am designing a Jenkins CICD pipeline at my organization and I have a following question. I am from a devops team that controls the Jenkins pipeline for multiple development teams. I basically want to write a Jenkins file with multiple stages that can be run by multiple teams. I understand that this Jenkins file can be checked into the Gitrepo of each team and it can invoke the complete pipeline as soon as the changes are done to the code repo. To make sure that this JenkinsFile is

Configure Jenkins 2.0 with Ansible

﹥>﹥吖頭↗ 提交于 2019-12-04 11:06:06
I am using Ansible for provision our servers, I installed the Jenkins 2.0 but it is becomeing with a startup configuration when I open the web UI. How can I do it with Ansible or shell or jenkins-cli. CentOS 7, Ansible 2.0.1.0. So, Installing Jenkins 2.0 from http://pkg.jenkins-ci.org/redhat-rc/jenkins-2.0-1.1.noarch.rpm rpm. Install java with yum. Service start jenkins. Open 192.168.46.10:8080, which is opening the Jenkins. In Web UI adding the initial admin password. In web UI select and install plugins. In web UI create a new admin user. The 5,6,7 points are all the startup config of the

Cannot use readMavenPom in Jenkinsfile

余生颓废 提交于 2019-12-04 08:56:01
问题 I am working on a Jenkinsfile for use with Jenkins 2.0. The readMavenPom method is not recognized. Is there some configuration I am missing to make this available? My Jenkinsfile: node { stage 'Checkout' checkout scm env.PATH = "${tool 'maven-3'}/bin:${env.PATH}" stage 'Build' def pom = readMavenPom file: 'pom.xml' echo "${pom}" sh "mvn -DskipTests=true verify" } When run, I get the following error: java.lang.NoSuchMethodError: No such DSL method 'readMavenPom' found among [AWSEBDeployment,

installing node on jenkins 2.0 using the pipeline plugin

牧云@^-^@ 提交于 2019-12-04 03:09:39
I am running the following docker image jenkinsci/jenkins:2.0-rc-1 to try out jenkins 2.0, and the "pipeline" view. I can't seem to install node. Here's my pipeline script: node { //tool([name: 'node-5.10.1', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation']) sh 'echo $(whoami)' sh 'node -v' } The response when this runs is: [ci] Running shell script + whoami + echo jenkins jenkins [Pipeline] sh [ci] Running shell script + node -v /../durable-3b0b1b07/script.sh: 2: /../durable-3b0b1b07/script.sh: node: not found Here's what i've tried: the jenkins NodeJS tool (which works correctly when

Error: “Expected named arguments” in parallel in Jenkins groovy script

…衆ロ難τιáo~ 提交于 2019-12-04 00:49:51
I have a Jenkins 2.0 pipeline, with a groovyscript like this: node('nnh561.raijin') { stage 'checkout' build('trunk/checkout') stage 'build' parallel( { build('trunk/build/gfortran') }, { build('trunk/build/ifort') } ) } Each of the individual jobs builds fine, but when I try to run the pipeline, it spits out this error when it hits the parallel step: java.lang.IllegalArgumentException: Expected named arguments but got [org.jenkinsci.plugins.workflow.cps.CpsClosure2@242d0d3a, org.jenkinsci.plugins.workflow.cps.CpsClosure2@9bf6d64] at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java

How to execute a command in a Jenkins 2.0 Pipeline job and then return the stdout

落花浮王杯 提交于 2019-12-03 09:49:10
Is there a better way to run a shell task in a Jenkins 2.0 pipeline and then return the stdout of the command. The only way I can get this to work is to pipe the output of the command to a file and then read the file in to a variable. sh('git config --get remote.origin.url > GIT_URL') def stdout = readFile('GIT_URL').trim() This seems like a really bad way to return the output. I was hoping I could do something like: def stdout = sh('git config --get remote.origin.url').stdout or def exitcode = sh('git config --get remote.origin.url').exitcode Is this possible? philbert Yes as luka5z mentioned

Jenkinsfile get current tag

回眸只為那壹抹淺笑 提交于 2019-12-03 07:26:33
Is there a way to get the current tag ( or null if there is none ) for a job in a Jenkinsfile? The background is that I only want to build some artifacts ( android APKs ) when this commit has a tag. I tried: env.TAG_NAME and binding.variables.get("TAG_NAME") both are always null - even though this ( https://issues.jenkins-ci.org/browse/JENKINS-34520 ) indicates otherwise I'd consider returnStdout rather than writing to a file: sh(returnStdout: true, script: "git tag --sort version:refname | tail -1").trim() All the other answers yield an output in any case even if HEAD is not tagged. The

Cannot use readMavenPom in Jenkinsfile

末鹿安然 提交于 2019-12-03 01:21:51
I am working on a Jenkinsfile for use with Jenkins 2.0. The readMavenPom method is not recognized. Is there some configuration I am missing to make this available? My Jenkinsfile: node { stage 'Checkout' checkout scm env.PATH = "${tool 'maven-3'}/bin:${env.PATH}" stage 'Build' def pom = readMavenPom file: 'pom.xml' echo "${pom}" sh "mvn -DskipTests=true verify" } When run, I get the following error: java.lang.NoSuchMethodError: No such DSL method 'readMavenPom' found among [AWSEBDeployment, archive, bat, build, catchError, checkout, deleteDir, dir, echo, emailext, error, fileExists, git, input

Maven installation settings not showing in Jenkins

有些话、适合烂在心里 提交于 2019-11-30 11:15:45
I have just installed Jenkins 2.6 (as a fresh install) but I can't seem to find the Maven installation options. Previously I would just be able to go to Jenkins configuration and in the Maven section there would be an option for MAVEN_HOME and to install Maven automatically. However this doesn't appear to be present for me. I have the Maven integration plugin installed. How can I get these to show? Omri Spector Since Jenkins 2.x you can find all the tool configurations (Maven, Ant, Gradle and even the JDK) under the "Global Tools" entry in Jenkins administration (Manage Jenkins). 来源: https:/

Jenkins Pipeline Fails if Step is Unstable

本秂侑毒 提交于 2019-11-30 08:26:22
Currently my pipeline fails (red), when a maven-job is unstable (yellow). node { stage 'Unit/SQL-Tests' parallel ( phase1: { build 'Unit-Tests' }, // maven phase2: { build 'SQL-Tests' } // shell ) stage 'Integration-Tests' build 'Integration-Tests' // maven } In this example the job Unit-Test's result is unstable, but is shown as failed in the pipeline. How can I change the jobs/pipeline/jenkins to have the (1) the pipeline step unstable instead of failed and (2) the pipeline's status unstable instead of failed. I tried adding the MAVEN_OPTS parameter -Dmaven.test.failure.ignore=true , but