jenkins-pipeline

Jenkins pipeline to build multiple projects in sequence?

倖福魔咒の 提交于 2020-01-05 07:08:16
问题 I am a novice when it comes to Jenkins. I would like to be able to take different projects and build them in sequence with each other with a Pipeline. I have noticed that Jenkins can run various stages in sequence or in parallel via a Pipeline. Is there a way for this to happen with running projects in sequence or in parallel that exists on the same node? 回答1: Yes, you can use build step to trigger any project (job) you want in Jenkins. See https://jenkins.io/doc/pipeline/steps/pipeline-build

Can Jenkins job watch one repo for changes, to trigger a build on another repo?

不羁岁月 提交于 2020-01-05 06:55:15
问题 Using Jenkins and pipelines; I have one repo which drives deployments and cloning its Jenkinsfile should kick off a new build; but I need the jenkins job which wraps it to watch another repo representing the site (not its build process), to watch for and build changes to the site, expected to change often, rather than the build process which hopefully will soon be stable and not subject to much additional change. Can anyone please advise me how it is I would accomplish this feat? 回答1: Use the

npm test does not detect new test file changes in jenkins

旧时模样 提交于 2020-01-04 14:19:35
问题 Jenkins/jest and CI , I have created a react APP using create-react-app and I use JEST for testing and I did some new changes in a file created app.test.js and committed to git-hub- hooked it with jenkins -when I run npm test in the local machine the tests are run fine and they all pass .. BUT when i run the jenkins pipeline script it says the following : No tests found related to files changed since last commit. Press a to run all tests, or run Jest with --watchAll. Watch Usage › Press a to

How to escape quotes in a AWS CLI in a Jenkins pipeline?

五迷三道 提交于 2020-01-04 06:50:13
问题 I'm trying to run an AWS CLI command to modify the DefaultActions block of one of my ALB listeners. I do this on my terminal. $ aws elbv2 modify-listener --listener-arn arn:aws:elasticloadbalancing:us-east-1:1234567890:listener/app/my-alb/123456789 --default-actions '[{"Type": "redirect", "RedirectConfig": {"Protocol": "HTTPS", "Port": "443", "Host": "#{host}", "Query": "#{query}", "Path": "/#{path}", "StatusCode": "HTTP_301"}}]' How would I code this in a Jenkins pipeline so the single

how to add gerrit-trigger events inside Jenkins pipeline code, inside Jenkinsfile

此生再无相见时 提交于 2020-01-04 05:45:07
问题 I would like to add gerrit trigger events inside Jenkinsfile, like we have in JobDSL, triggers { upstream('pipeline_properties', 'UNSTABLE') gerrit { events { refUpdated() } project('reg_exp:jenkins', ["plain:${jenkins_branch}"]) } } Is this something possible in pipeline code, could able to find some things like cron and stuffs under triggers but not able to get a reference how to add the gerrit-trigger event inside. 回答1: Here is one working Jenkinsfile covers the gerrit trigger event part,

How to set job properties for jobs within a Jenkins multi-branch pipeline project?

*爱你&永不变心* 提交于 2020-01-04 04:09:32
问题 Does anyone know the correct method for setting job properties, specifically build triggers, from within a Jenkinsfile? (declarative pipeline script, in a multi-branch pipeline job). For clarity I need to set specific build triggers for underlying jobs in a multibranch project. The triggers for the overarching multibranch project I can configure in the GUI. Have tried methods listed here: Jenkins multi-branch pipeline and specifying upstream projects Jenkins: Trigger Multi-branch pipeline on

Jenkins Pipeline - Reading previous stage log

泄露秘密 提交于 2020-01-04 03:53:06
问题 Consider a Jenkins Pipeline with two stages, Stage A then Stage B . In Stage B, is it possible to parse the logs of Stage A for some particular text? 回答1: There's been an update since July 28th ! As mentionned in this answer, as of version 2.4 of Pipeline: Nodes and Processes you can use: def out = sh script: 'command', returnStdout: true At least it's much more simple and clean than outputting to a file and reading the file afterwards. 回答2: Use tee to split the output to both stdout and file

Passing 'build with parameters' to Jenkinsfile from scm in pipeline

喜欢而已 提交于 2020-01-04 03:17:24
问题 I am on jenkins 2.x and using pipeline. I have configured the job to be built with param and have a string param : I also get the Jenkinsfile from github ( pipeline from script) : Now in my Jenkinsfile, I am using the param : ${githubUrl} and it throws error : stdout: stderr: fatal: '${githubUrl}' does not appear to be a git repository So if directly write the pipeline script , this works but fetching from scm fails. Any ideas how to get around it ? 回答1: Use url: githubUrl without dollar sign

Can I create 'shared library' in Jenkins Pipeline in other language than Groovy?

孤人 提交于 2020-01-04 00:39:06
问题 I have python script which does a REST command and processes the result. I want this script to be used by different Jenkins Pipelines, one way I found through Jenkins official documentation is to use 'Shared library' and that examples(also others example which I found online) they use the Groovy. My question is, is it possible to create a shared lib in other language than Groovy? For ex. python? 回答1: Short answer is no. All Jenkins Pipeline execution (right now) is specialized Groovy that is

Jenkins pipeline ansicolor console output

大城市里の小女人 提交于 2020-01-03 17:42:28
问题 I know it's possible to display color in the console output using the AnsiColor plugin. I tested a basic example below: // This shows a simple build wrapper example, using the AnsiColor plugin. node { // This displays colors using the 'xterm' ansi color map. ansiColor('xterm') { // Just some echoes to show the ANSI color. stage "\u001B[31mI'm Red\u001B[0m Now not" } } However, this example is too basic and essentially hardcoded. Is it possible to utilize AnsiColor to make the entire console