jenkins-pipeline

How to resolve “Cannot retrieve .Id from docker” when building Docker image using Jenkins pipeline

时光毁灭记忆、已成空白 提交于 2019-12-03 10:55:58
问题 I am using a Jenkins pipeline to build a Dockerfile. The dockerfile successfully goes through all steps, and creates the docker image. As shown: Step 16/19 : FROM base AS final ---> <id> Step 17/19 : WORKDIR /app ---> Using cache ---> <id> Step 18/19 : COPY --from=publish /app . ---> Using cache ---> <id> Step 19/19 : ENTRYPOINT ["", "myapp.dll"] ---> Using cache ---> <id> Successfully built cb3y81938e88 Successfully tagged myapp:latest However, after this, the shell Fails with the following

try/catch/finally masks Jenkinsfile problems in case of groovy compiler exceptions

三世轮回 提交于 2019-12-03 10:54:43
问题 I have code similar to the one below in my Jenkinsfile: node { checkout scm // do some stuff try { // do some maven magic } catch (error) { stage "Cleanup after fail" emailext attachLog: true, body: "Build failed (see ${env.BUILD_URL}): ${error}", subject: "[JENKINS] ${env.JOB_NAME} failed", to: 'someone@example.com' throw error } finally { step $class: 'JUnitResultArchiver', testResults: '**/TEST-*.xml' } } If the above code fails because of some jenkins-pipeline related errors in the try {

How do I make Jenkins 2.0 execute a sh command in the same directory as the checkout?

送分小仙女□ 提交于 2019-12-03 10:30:19
问题 Here's my Jenkins 2.x pipeline: node ('master'){ stage 'Checkout' checkout scm stage "Build Pex" sh('build.sh') } When I run this pipeline the checkout puts the code into to the workspace as expected, however instead of expecting to find the script in workspace/ (it's really there!), it looks in an unrelated directory: workspace@tmp/durable-d812f509. Entering stage Build Pex Proceeding [Pipeline] sh [workspace] Running shell script + build.sh /home/conmonsysdev/deployments/jenkins_ci_2016

Grouping and decorating groups of parameters in Jenkins

三世轮回 提交于 2019-12-03 09:57:33
问题 I'm writing a Jenkins pipeline job with quite a few parameters and I'm looking for a way to visually group them together so they will be easier to understand -rather than have them all just thrown in there. I'll settle for anything that at least hints a the fact that these parameters are related to each other. Could be a header, could be boxes. Is there any plugin that will help me decorate my inputs this way? 回答1: So, after much searching the web I finally found a plugin that does the trick.

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

Jenkins pipeline (parallel && dynamically)?

核能气质少年 提交于 2019-12-03 09:23:15
Question I have simple parallel pipeline (see code) which I use together with Jenkins 2.89.2. Additionally I use parameters and now want to be able to in-/decrease the number of deployVM A..Z stages automatically by providing the parameter before job execution. How can I dynamically build my pipeline by providing a parameter? Researched so far: Jenkins pipeline script created dynamically - Not getting this to work with my Jenkins version Can I create dynamically stages in a Jenkins pipeline? - Not working either Code The pseudo code of what I want - dynamic generation: pipeline { agent any

Complex and long single-job Jenkins Job Pipeline Builds: There yet?

我怕爱的太早我们不能终老 提交于 2019-12-03 09:08:54
TL;DR Does it make sense to have one single Jenking Job Pipeline job for a full long-running deployment / "build" chain in the free Jenkins, given that resumable checkpoint s are not available? Prelude I'm looking at the current incarnation of Jenkins' the open/free Pipeline Bundle . I'll note that I think that what you get for free here is quite simply amazing, seeing as most of the stuff (workflow-jobs themselves, stage-view , ...) was only part of the commercial enterprise bundle of CloudBees a year or two back. Single and Multiple Jobs It also seems to me that given the stash ing abilities

Jenkins pipeline plugin: set the build description

此生再无相见时 提交于 2019-12-03 08:58:31
问题 I'm trying to replace our current build pipeline, currently hacked together using old-school Jenkins jobs, with a new job that uses the Jenkins pipeline plugin, and loads a Jenkinsfile from the project repository. One thing that the legacy job did was set the build description to include the Mercurial hash, username and current version using the Description setter plugin, so that builds are easy to find. Is there a way to replicate/emulate this behaviour with the Jenkins pipeline plugin? 回答1:

Use private docker registry with Authentication in Jenkinsfile

╄→гoц情女王★ 提交于 2019-12-03 08:52:01
问题 How can I teach my Jenkisfile to login via basic auth in this setup? I'm using a custom docker image for my Jenkins build. As described in the documentation here I defined a docker agent like so: pipeline { agent { docker { image 'registry.az1:5043/maven-proto' registryUrl 'https://registry.az1' args '-v /var/jenkins_home/.m2:/root/.m2' } } options { timeout(time: 1, unit: 'HOURS') buildDiscarder(logRotator(numToKeepStr:'10')) } stages { stage ('Build') { steps{ sh ... } } stage ('Test') {

Jenkins Global environment variables in Jenkinsfile

佐手、 提交于 2019-12-03 08:40:42
问题 How do I invoke Global environment variables in Jenkinsfile? For example, if I have a variable - name:credentialsId value:xxxx-xxxx-xxxxx-xxxxxxxxx How do I use it in the groovy script? I tried ${credentialsId} , but it didn't work. It will just give error: java.lang.NoSuchMethodError: No such DSL method '$' found among steps [ArtifactoryGradleBuild, ........ 回答1: In a Jenkinsfile, you have the "Working with the Environment" which mentions: The full list of environment variables accessible