jenkins-pipeline

Jenkins pipeline git command submodule update

断了今生、忘了曾经 提交于 2019-12-03 05:42:28
问题 I want to update submodule on git clone. Is there a way to do this with Jenkins pipeline Git command? Currently I'm doing this... git branch: 'master', credentialsId: 'bitbucket', url: 'ssh://bitbucket.org/hello.git' It doesn't however update submodule once cloned 回答1: With the current Git plugin, you don't even need that. The GIT plugin supports repositories with submodules which in turn have submodules themselves. This must be turned on though: in Job Configuration -> Section Source Code

Use .gdsl file in a Java project in IntelliJ

时间秒杀一切 提交于 2019-12-03 05:42:22
问题 I have a file pipeline.gdsl that contains the Syntax for my Jenkins Pipeline DSL. Following this blog post I put the file into the /src folder of my Java project. When I now edit my Jenkinsfile (residing in the root folder of my project), I don't get any code completion / syntax explanation as I would expect. My project is a Java / Gradle project and I cannot make a Groovy project out of it. Is there some other way to make IntelliJ aware of the .gdsl file and provide code completion? 回答1: The

Jenkins Pipeline Builds: Viewing Workspace in the UI

被刻印的时光 ゝ 提交于 2019-12-03 05:37:11
We are now experimenting with multi-branch Pipeline builds. The main advantage of the feature is that it allows us to automatically create new Jenkins jobs whenever a new branch is created. However, it also is a bit more difficult to implement than the old way of selecting how to do the build using the UI. Plus, certain features seem to be missing. For example, in Jenkins Freestyle jobs, we are able to use the Jenkins UI to browse through the workspace, download individual files, and even wipe out the workspace. We found this helpful when builds went awry or if the developer needed a

How to write Pipeline to discard old builds?

喜你入骨 提交于 2019-12-03 05:21:56
问题 The groovy syntax generator is NOT working for sample step properties: Set Job Properties . I've selected Discard old builds and then entered 10 in the Max # of builds to keep field and then Generate Groovy and nothing shows up. Jenkins version: 2.7 回答1: As for declarative syntax, you can use the options block: pipeline { options { buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30')) } ... } Parameters for logRotator (from the source code): daysToKeepStr : history is

Gitlab webhook does not trigger a build on jenkins

爱⌒轻易说出口 提交于 2019-12-03 05:05:58
I've a group of multibranch pipeline jobs generated with the following piece groovy script: [ 'repo1', 'repo2', ].each { service -> multibranchPipelineJob(service) { displayName(service) branchSources { git { remote("git@gitlab.com:whatever/${service}.git") credentialsId('gitlab-ssh-key') } } orphanedItemStrategy { discardOldItems { daysToKeep(0) numToKeep(30) } } triggers { periodic(5) } } } and in each repo a Jenkinsfile that looks as follows: #!/usr/bin/env groovy properties([ gitLabConnection('ci@gitlab.com'), pipelineTriggers([ [ $class : 'GitLabPushTrigger', triggerOnPush : true,

How to wait for user input in a Declarative Pipeline without blocking a heavyweight executor

爱⌒轻易说出口 提交于 2019-12-03 04:55:20
I'm rebuilding an existing build pipeline as a jenkins declarative pipeline (multi-branch-pipeline) and have a problem handling build propagation. After packaging and stashing all relevant files the pipeline is supposed to wait for user input to trigger deployment. If i just add an input step the current build-node is blocked. As this executor is pretty heavy i would like to move this step to a more lightweight machine. Initially i did the job as a scripted pipeline and just created two different node('label') blocks. is there a way for me to do something similar with the declarative syntax?

How do I stop a running container in Jenkinsfile?

…衆ロ難τιáo~ 提交于 2019-12-03 04:51:29
I have a Jenkinsfile or a Jenkins pipeline which creates a new image and starts a container out of that image. It works well for the first time. But on subsequent runs, I want the previous container to be stopped and removed. My Jenkinsfile is as follows: node { def commit_id stage('Preparation') { checkout scm sh "git rev-parse --short HEAD > .git/commit-id" commit_id = readFile('.git/commit-id').trim() } stage('docker build/push') { docker.withRegistry('https://index.docker.io/v1/', 'dockerhub') { def app = docker.build("my-docker-id/my-api:${commit_id}", '.').push() } } stage('docker stop

How to disable command output in jenkins pipeline build logs

♀尐吖头ヾ 提交于 2019-12-03 04:33:54
I am using Jenkinsfile for scripting of a pipeline. Is there any way to disable printing of executed shell commands in build logs? Here is just a simple example of a jenkins pipeline: node{ stage ("Example") { sh('echo shellscript.sh arg1 arg2') sh('echo shellscript.sh arg3 arg4') } } which produces the following output in console log: [Pipeline] node Running on master in /var/lib/jenkins/workspace/testpipeline [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] sh [testpipeline] Running shell script + echo shellscript.sh arg1 arg2 shellscript.sh arg1 arg2 [Pipeline] sh [testpipeline]

How to set and reference a variable in a Jenkinsfile

早过忘川 提交于 2019-12-03 04:27:17
I have a declarative pipeline script for my multibranch project in which I would like to read a text file and store the result as a string variable to be accessed by a later step in the pipeline. Using the snippet generator I tried to do something like this: filename = readFile 'output.txt' For which filename would be my string. I get an error in the Jenkins console output: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 30: Expected a step @ line 30, column 5. filename = readFile 'output.txt' Do I need to use a withEnv step to set the output of

Copy artifact within a jenkins pipeline

╄→гoц情女王★ 提交于 2019-12-03 04:06:56
I have a Jenkins pipeline job that archives an Artifact in its first phase, I then need to copy that Artifact in another stage of the pipeline build node { stage 'Stage 1 of build' // Run tests, if successful archive the artifact archiveArtifacts artifacts: 'build/test.js', excludes: null stage 'Stage 2 of build' // want to copy artifact from stage 1 of the build step([$class: 'CopyArtifact', filter: 'build/test.js', fingerprintArtifacts: true, flatten: true, projectName: 'echo-develop-js-pipeline', selector: [$class: 'WorkspaceSelector'], target: './client/public/vendor/echo/']) } With this I