jenkins-pipeline

Jenkinsfile build log

二次信任 提交于 2019-12-04 00:05:59
问题 Is there any builtin variable that gives access to the text of the currently executing build? I tried using something like currentBuild.log , currentBuild.buildLog but without any luck. 回答1: Actually it is possible using currentBuild.rawBuild.log or better (not deprecated) currentBuild.rawBuild.getLog(100) (for the last 100 lines), reference: http://javadoc.jenkins-ci.org/hudson/model/Run.html#getLog-int- 回答2: I searched a lot for a solution to analyze the log. use rawBuild was not OK,

Jenkins-pipeline Extract and Set variables from properties file in groovy

十年热恋 提交于 2019-12-03 21:54:49
问题 To begin i'm writing the pipeline entirely as groovy to be checked in to git. Please do not provide any gui necessary solutions. My Problem statement is: Extract a variable from a file and set it equal to a groovy object. What i've tried def SERVICE_MAJOR_VERSION node { runGitClone(GIT_REPO_URL, GIT_HASH) def conf = readFile("gradle.properties") echo conf //THE BELOW COMMENT DOESN'T WORK //SERVICE_MAJOR_VERSION = loadEnvFromFile("SERVICE_VERSION_MAJOR", "gradle.properties", true, SERVICE

Jenkins continue pipeline on failed stage

混江龙づ霸主 提交于 2019-12-03 21:11:53
问题 I have a jenkins setup with a bunch of pipelines. I wrote a new pipeline which can start all pipelines at once. I would like to build other stages, even if one of them fails. The script currently looks like this stage 'CentOS6' build 'centos6.testing' stage 'CentOS7' build 'centos7.testing' stage 'Debian7' build 'debian7-x64.testing' stage 'Debian8' build 'debian8-x64.testing' The build scripts itself contain the node they should run on. How can the script continue with the following stages

How to set PATH in Jenkins Declarative Pipeline

冷暖自知 提交于 2019-12-03 19:47:49
问题 In Jenkins scripted pipeline you can set PATH env variable like this : node { git url: 'https://github.com/jglick/simple-maven-project-with-tests.git' withEnv(["PATH+MAVEN=${tool 'M3'}/bin"]) { sh 'mvn -B verify' } } Notice the PATH+MAVEN as explained here https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-withenv-code-set-environment-variables : A list of environment variables to set, each in the form VARIABLE=value or VARIABLE= to unset variables otherwise defined. You may

How to use post steps with Jenkins pipeline on multiple agents?

依然范特西╮ 提交于 2019-12-03 18:48:25
问题 When using the Jenkins pipeline where each stage runs on a different agent, it is good practice to use agent none at the beginning: pipeline { agent none stages { stage('Checkout') { agent { label 'master' } steps { script { currentBuild.result = 'SUCCESS' } } } stage('Build') { agent { label 'someagent' } steps { bat "exit 1" } } } post { always { step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "test@test.com", sendToIndividuals: true]) } } } But doing this leads to

npm install fails in jenkins pipeline in docker

故事扮演 提交于 2019-12-03 18:28:07
问题 I'm following a tutorial about Jenkins pipeline and I can get a "hello world" working under at node 6.10 docker container. But, when I added a default EmberJS app (using ember init ) to the repo and attempt to build that in the pipeline, it fails when running npm install (because of directory access issues). The Jenkinsfile can be seen here: https://github.com/CloudTrap/pipeline-tutorial/blob/fix-build/Jenkinsfile The error message printed by the build is (which is installed locally and run

Deploying An Angular application using continuous integration from git or gitLab

别来无恙 提交于 2019-12-03 17:32:37
I am looking to deploy Angular 5 application with continuous integration from bitbucket on an Apache server Now because I am new to the field, I am unaware of the possible options to do this Like do we need to integrate webpack with Jenkins, or do we need to write some other code on Jenkins, or we can do it without Jenkins and do we need to integrate it along with Sonar Some pages do not give any clue about webpack, while some say you just have to write webpack script in Jenkins Anyone having experience in this, please enlighten us If you are using angular cli to building the application, then

How to define and iterate over map in Jenkinsfile

元气小坏坏 提交于 2019-12-03 17:10:21
My knowledge of groovy doesn't go very far beyond what little I know about Jenkinsfiles. I'm trying to figure out if it's possible to have a map defined in a Jenkinsfile that can then be applied in a "for loop" fashion. I have these variables: mymap = { "k1": "v1" "k2": "v2" "k3": "v3" } I have a stage in my Jenkinsfile that looks like this: stage('Build Image') { withCredentials([[<the credentials>]) { sh "make build KEY={k1,k2,k3} VALUE='{v1,v2,v3}'" } Is there a way to make a Build Image stage for each of the pairings in mymap ? I haven't had any luck with what I've tried. There are some

Multiple projects sharing a jenkinsfile

穿精又带淫゛_ 提交于 2019-12-03 16:32:17
I have multiple projects with similar build steps and I am looking into reusing a Jenkinsfile pipeline across these projects. I am having a hard time to find documentation on how to implement such an standard (to my opinion) setup. Here are my requirements : 1) a Jenkinsfile is stored in repo, shared across multiple projects 2) Each project has its own parameter : the project location in the repo. 3) Each project should be independent in Jenkins from a user perspective at least, meaning for example the executions and logs are available in each project's entry in Jenkins How can I achieve this?

How to approve script snippets from a jenkinsfile via the groovy script console?

佐手、 提交于 2019-12-03 16:24:42
问题 In my jenkins pipeline file I use the JsonSlurperClassic to read build configurations from a .json file. This however introduces code that needs to be approved over the in-process Script Approval page. This works fine when I do it over the GUI. However I also have a script that automatically sets up my jenkins machine which should create a ready-to-work machine that does not require further GUI operations. This script already uses the jenkins script console to approve slave start-up commands.