jenkins-pipeline

Why won't groovy run in Jenkins pipeline?

大憨熊 提交于 2019-12-02 03:37:35
I am currently trying to run a groovy script from my pipeline as one of my nodes, but I ran into this error: [CompanyName] Running shell script + ./ideainspect.groovy env: groovy: No such file or directory Also, I tried installing the plugin for groovy, but for some reason, it won't install. Whenever I refresh the page for tools, the installer goes away. Am I installing groovy wrong? Please help! Edit: Relevant Data stage 'Static Analysis' node { dir("Android/btMobileApp") { sh "./ideainspect.groovy" sh "./gradlew checkstyle lintDebug" } } And the ideainspect.groovy file is an executable with

Using an arbitrary plugin in Jenins 2 Pipeline scripts

狂风中的少年 提交于 2019-12-02 01:02:07
问题 Using the Snippet Generator tool in Jenkins 2, I can setup a plugin like I would within a job, and then it will generate me the Groovy I can use in my Pipeline script. But what if the plugin I am interested in instrumenting isn't listed in the "Sample Step" drop down in the Snippet Generator ? How do I determine how to create a script block to instrument the plugin I want to use? In my case, I would like to use the "Flexible Publish" plugin within my Pipeline script. 回答1: You can't use

Jenkins Pipelines: Why is CPS Global Lib not loading?

风格不统一 提交于 2019-12-01 23:19:15
I'm following the tutorial on the pipeline library plugin . I made a repository containing the following files: D:. │ Test.groovy │ ├───src └───vars helloWorld.groovy helloWorld.groovy contains: def call(name){ echo "Hello world, ${name}" } Test.groovy contains: helloWorld("Joe") I installed all the pipeline plugins, in particular workflow-cps-global-lib-plugin. Then I created a new pipeline job in which I load this repository and set the Script Path to Test.groovy. When I run this job I get the following error: java.lang.NoSuchMethodError: No such DSL method 'helloWorld' found among [archive,

Post failure block in Jenkinsfile is not working

淺唱寂寞╮ 提交于 2019-12-01 22:47:49
I'm trying a post failure action with a parallel step but it never works. This is my Jenkinsfile: pipeline { agent any stages { stage("test") { steps { withMaven( maven: 'maven3', // Maven installation declared in the Jenkins "Global Tool Configuration" mavenSettingsConfig: 'maven_id', // Maven settings.xml file defined with the Jenkins Config File Provider Plugin mavenLocalRepo: '.repository') { // Run the maven build sh "mvn --batch-mode release:prepare -Dmaven.deploy.skip=true" --> it will always fail } } } stage("testing") { steps { parallel ( phase1: { sh 'echo phase1' }, phase2: { sh

Running nested commands in Jenkins pipeline shell

邮差的信 提交于 2019-12-01 22:10:09
问题 I want to run nested shell command for example like this in Jenkins pipeline: docker stop $(docker ps -aq) Unfortunately when I format it into pipeline syntax: sh('docker stop $(docker ps -aq)') Jenkins does not seem to run them correctly, but outputs that: "docker stop" requires at least 1 argument(s). I tried to run the command under bash like told here: Run bash command on jenkins pipeline But end up with similar issue. Any ideas how to solve this? 回答1: This becomes easier for Jenkins

Using an arbitrary plugin in Jenins 2 Pipeline scripts

时光怂恿深爱的人放手 提交于 2019-12-01 20:32:52
Using the Snippet Generator tool in Jenkins 2, I can setup a plugin like I would within a job, and then it will generate me the Groovy I can use in my Pipeline script. But what if the plugin I am interested in instrumenting isn't listed in the "Sample Step" drop down in the Snippet Generator ? How do I determine how to create a script block to instrument the plugin I want to use? In my case, I would like to use the " Flexible Publish " plugin within my Pipeline script. You can't use plugins which are not compatible with pipeline generally. Plugins need to be modified more or less to be

Get a list of filenames in a given folder in Jenkinsfile (Groovy)

佐手、 提交于 2019-12-01 18:03:00
I cannot create a simple list of filenames in a given directory in a scripted Jenkins Pipeline. I tried many Groovy Script examples posted on SO and other forums but either the feature is blocked or I get method not found or whatever. This seems to be the easiest def DOCKER_FILES_DIR = './dockerfiles' // ... def dir = new File(DOCKER_FILES_DIR); def dockerfiles = []; dir.traverse(type: FILES, maxDepth: 0) { dockerfiles.add(it) } But this resolves the relative path incorrectly, so I get this error: java.io.FileNotFoundException: /./dockerfiles I also tried to wrap it in dir with: def DOCKER

Jenkins Multibranch Pipeline fails because it runs in Groovy Sandbox

百般思念 提交于 2019-12-01 17:55:50
问题 My Jenkins CI/CD build configuration was working and nothing changed until my last pull request and I need to get this working again. The Multibranch Pipeline is configured to run a jenkinsfile from BitBucket SCM but this is now failing with the following error; groovy.lang.MissingPropertyException: No such property: pipeline for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall

Jenkins Multibranch Pipeline fails because it runs in Groovy Sandbox

*爱你&永不变心* 提交于 2019-12-01 17:45:36
My Jenkins CI/CD build configuration was working and nothing changed until my last pull request and I need to get this working again. The Multibranch Pipeline is configured to run a jenkinsfile from BitBucket SCM but this is now failing with the following error; groovy.lang.MissingPropertyException: No such property: pipeline for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:130) Script Security Plugin is installed and the In-process Script Approval

Permission Denied while trying to connect to Docker Daemon while running Jenkins pipeline in Macbook

随声附和 提交于 2019-12-01 17:09:43
I am trying to run Jenkins pipeline job in my macbook. I also have docker instance running locally. Initially I got the " docker command not found " error while running the Jenkins Job. I fixed the error by adding a symlink " ln -f -s /Applications/Docker.app/Contents/Resources/bin/* /usr/local/bin " I also applied these two changes so that jenkins user has the access to the docker directory chmod -R 777 /Users/myUserName/Library/Containers/com.docker.docker/ chmod -R 777 /Users/myUserName/Library/Containers/com.docker.helper/ I am getting below errors : Got permission denied while trying to