Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39664

Docker builds do not work with Kubernetes Pipeline plugin

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins 2.19.1
      Kubernetes-Pipeline-Plugin 0.9
      Docker-Workflow-Plugin 1.9

      I have setup a Kubernetes Pipeline (see below) which is working fine, as long as I do use shell-scripts to generate the Docker-Image. As soon as I try to use the docker-Workflow plugin, the script comes back, with an exception in a (not defined by myself) dockerFingerprintFrom-step. This step does not seem to be able to find the generated docker-image anymore. Therefor I do assume, that this step is then not run in the container, where I build the image.

      Any help is appreciated.

      podTemplate(label: 'docker-mysql', containers: [
          containerTemplate(name: 'docker', image: 'docker:1.12.3-dind', ttyEnabled: true, command: 'cat', privileged: true, instanceCap: 1),
          containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:2.62-alpine', args: '${computer.jnlpmac} ${computer.name}'),
        ],
        volumes: [
              hostPathVolume(mountPath: "/var/run/docker.sock", hostPath: "/var/run/docker.sock")
        ]) {
        node() {
          stage('Preparation') { // for display purposes
            git url: 'https://github.com/repo/docker-mysql.git'
            container('docker') {
              stage('Build the docker image') {
      
              sh 'docker build -t devopskube/mysql:latest .'
              sh 'docker inspect -f {{.Id}} repo/mysql:latest'
      
              id = sh (
                    script: 'docker inspect -f {{.Id}} repo/mysql:latest',
                    returnStdout: true
                   ).trim()
              }
            }
          }
        }
      

          [JENKINS-39664] Docker builds do not work with Kubernetes Pipeline plugin

          Markus May added a comment -

          Should I provide any additional information?

          Markus May added a comment - Should I provide any additional information?

          Same issue with kubernetes-plugin 0.10.
          docker.build "myimage" fails, but if i replace it to sh 'docker build -t myimage .' it works.

          Roman Safronov added a comment - Same issue with kubernetes-plugin 0.10. docker.build "myimage" fails, but if i replace it to sh 'docker build -t myimage .' it works.

          this may be fixed by JENKINS-42048. Anything running inside container() before that's fixed may break

          Carlos Sanchez added a comment - this may be fixed by JENKINS-42048 . Anything running inside container() before that's fixed may break

          There seems to be similar issue with running the containers. Some things I noticed:
          When using the default docker:17.06 image, the command gets cutoff at around 1023 characters (busybox's ash's default limit).

          From console log (sensitive details masked to same character length. Note that there's ESC code (ASCII 27) after '/hom/jenkins # ' and on last line after '> ' in case JIRA drops them):

          Executing shell script inside container [docker-cmds] of pod [jenkins-slave-x0z55-qkk43]
          Executing command: "docker" "run" "-t" "-d" "-u" ":" "-w" "/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA" "-v" "/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:rw,z" "-v" "/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA@tmp:/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA@tmp:rw,z" "-e" "BRANCH_NAME=newjenkins" "-e" "BUILD_DISPLAY_NAME=#20" "-e" "BUILD_ID=20" "-e" "BUILD_NUMBER=20" "-e" "BUILD_TAG=jenkins-companyx-io-projectxxxxxxxxx-newjenkins-20" "-e" "BUILD_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/" "-e" "CLASSPATH=" "-e" "EXECUTOR_NUMBER=0" "-e" "HUDSON_HOME=/var/jenkins_home" "-e" "HUDSON_SERVER_COOKIE=39f88e47ba12150f" "-e" "HUDSON_URL=http://jenkins-prod/" "-e" "JENKINS_HOME=/var/jenkins_home" "-e" "JENKINS_NODE_COOKIE=7b758060-53f9-4f4e-a489-9d9402f78e25" "-e" "JENKINS_SERVER_COOKIE=39f88e47ba12150f" "-e" "JENKINS_URL=http://jenkins-prod/" "-e" "JOB_BASE_NAME=newjenkins" "-e" "JOB_DISPLAY_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/display/redirect" "-e" "JOB_NAME=companyx-io/projectxxxxxxxxx/newjenkins" "-e" "JOB_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/" "-e" "NODE_LABELS=dind jenkins-slave-x0z55-qkk43" "-e" "NODE_NAME=jenkins-slave-x0z55-qkk43" "-e" "RUN_CHANGES_DISPLAY_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/display/redirect?page=changes" "-e" "RUN_DISPLAY_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/display/redirect" "-e" "WORKSPACE=/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA" "--entrypoint" "cat" "callstats/mongo_docker_smallfiles:3.2" 
          printf "EXITCODE %3d" $?; exit
          /home/jenkins # "docker" "run" "-t" "-d" "-u" ":" "-w" "/home/jenkins/workspace/
          
          projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA
          
          " "-v" "/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44B
          
          H62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:/home/jenkins/workspace/projectxxxxxxxxx_newjen
          
          kins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:rw,z" "-v" "/home/jenk
          
          ins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEY
          
          J6TXYACLLYI4AA@tmp:/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6H
          
          BP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA@tmp:rw,z" "-e" "BRANCH_NAME=newjenki
          
          ns" "-e" "BUILD_DISPLAY_NAME=#20" "-e" "BUILD_ID=20" "-e" "BUILD_NUMBER=20" "-e"
          
           "BUILD_TAG=jenkins-companyx-io-projectxxxxxxxxx-newjenkins-20" "-e" "BUILD_URL=
          
          http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/" "-e
          
          " "CLASSPATH=" "-e" "EXECUTOR_NUMBER=0" "-e" "HUDSON_HOME=/var/jenkins_home" "-e
          
          " "HUDSON_SERVER_COOKIE=39f88e47ba12150f" "-e" "HUDSON_URL=http://jenkins-prod
          > printf "EXITCODE %3d" $?; exit
          > ERROR: Timeout after 180 seconds
          

          The timeout is likely caused by command getting cut-off before quotes get closed.JenkinsfileNew
          However, when running long commands directly with sh, they get processed normally

          projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA] Running shell script
          + echo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994
          [Pipeline] sh
          

          When using image which uses different shell (in this case /bin/sh symlinked to /bin/bash), the command seems to get executed, but likely the output doesn't reach Docker pipeline plugin as it will try to run command `docker inspect -f .Config.Hostname ""` after it (ex. missing the container id).

          So it seems like the way commands are executed by Docker plugin (and likely others) is different from sh pipeline step. Unfortunately I don't really have deeper understanding regarding how shell commands get executed in Jenkins, so I don't think I can provide further help.

          I have attached the pipeline script which I have been using to test the issue (you can change callstats/docker-with-bash:17.06.0 to docker:17.06.0 in order to test with busybox's ash).

          Eljas Alakulppi added a comment - There seems to be similar issue with running the containers. Some things I noticed: When using the default docker:17.06 image, the command gets cutoff at around 1023 characters (busybox's ash's default limit). From console log (sensitive details masked to same character length. Note that there's ESC code (ASCII 27) after '/hom/jenkins # ' and on last line after '> ' in case JIRA drops them): Executing shell script inside container [docker-cmds] of pod [jenkins-slave-x0z55-qkk43] Executing command: "docker" "run" "-t" "-d" "-u" ":" "-w" "/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA" "-v" "/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:rw,z" "-v" "/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA@tmp:/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA@tmp:rw,z" "-e" "BRANCH_NAME=newjenkins" "-e" "BUILD_DISPLAY_NAME=#20" "-e" "BUILD_ID=20" "-e" "BUILD_NUMBER=20" "-e" "BUILD_TAG=jenkins-companyx-io-projectxxxxxxxxx-newjenkins-20" "-e" "BUILD_URL=http: //jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/" "-e" "CLASSPATH=" "-e" "EXECUTOR_NUMBER=0" "-e" "HUDSON_HOME=/ var /jenkins_home" "-e" "HUDSON_SERVER_COOKIE=39f88e47ba12150f" "-e" "HUDSON_URL=http://jenkins-prod/" "-e" "JENKINS_HOME=/ var /jenkins_home" "-e" "JENKINS_NODE_COOKIE=7b758060-53f9-4f4e-a489-9d9402f78e25" "-e" "JENKINS_SERVER_COOKIE=39f88e47ba12150f" "-e" "JENKINS_URL=http://jenkins-prod/" "-e" "JOB_BASE_NAME=newjenkins" "-e" "JOB_DISPLAY_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/display/redirect" "-e" "JOB_NAME=companyx-io/projectxxxxxxxxx/newjenkins" "-e" "JOB_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/" "-e" "NODE_LABELS=dind jenkins-slave-x0z55-qkk43" "-e" "NODE_NAME=jenkins-slave-x0z55-qkk43" "-e" "RUN_CHANGES_DISPLAY_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/display/redirect?page=changes" "-e" "RUN_DISPLAY_URL=http://jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/display/redirect" "-e" "WORKSPACE=/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA" "--entrypoint" "cat" "callstats/mongo_docker_smallfiles:3.2" printf "EXITCODE %3d" $?; exit /home/jenkins #  "docker" "run" "-t" "-d" "-u" ":" "-w" "/home/jenkins/workspace/ projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA " " -v " " /home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44B H62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:/home/jenkins/workspace/projectxxxxxxxxx_newjen kins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA:rw,z " " -v " " /home/jenk ins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEY J6TXYACLLYI4AA@tmp:/home/jenkins/workspace/projectxxxxxxxxx_newjenkins-Y3XWAWE6H BP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA@tmp:rw,z " " -e " " BRANCH_NAME=newjenki ns " " -e " " BUILD_DISPLAY_NAME=#20 " " -e " " BUILD_ID=20 " " -e " " BUILD_NUMBER=20 " " -e" "BUILD_TAG=jenkins-companyx-io-projectxxxxxxxxx-newjenkins-20" "-e" "BUILD_URL= http: //jenkins-prod/job/companyx-io/job/projectxxxxxxxxx/job/newjenkins/20/ " " -e " " CLASSPATH= " " -e " " EXECUTOR_NUMBER=0 " " -e " " HUDSON_HOME=/ var /jenkins_home " " -e " " HUDSON_SERVER_COOKIE=39f88e47ba12150f " " -e " " HUDSON_URL=http: //jenkins-prod > printf "EXITCODE %3d" $?; exit > ERROR: Timeout after 180 seconds The timeout is likely caused by command getting cut-off before quotes get closed.JenkinsfileNew However, when running long commands directly with sh, they get processed normally projectxxxxxxxxx_newjenkins-Y3XWAWE6HBP75UYAB44BH62V5DLTD2JHCZ5NEYJ6TXYACLLYI4AA] Running shell script + echo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 [Pipeline] sh When using image which uses different shell (in this case /bin/sh symlinked to /bin/bash), the command seems to get executed, but likely the output doesn't reach Docker pipeline plugin as it will try to run command `docker inspect -f .Config.Hostname ""` after it (ex. missing the container id). So it seems like the way commands are executed by Docker plugin (and likely others) is different from sh pipeline step. Unfortunately I don't really have deeper understanding regarding how shell commands get executed in Jenkins, so I don't think I can provide further help. I have attached the pipeline script which I have been using to test the issue (you can change callstats/docker-with-bash:17.06.0 to docker:17.06.0 in order to test with busybox's ash).

          It looks like I'm being hit by the same bug.

          Using Jenkins 2.75 with the below plugins installed:

          • docker commons 1.8
          • docker workflow (aka pipeline) 1.12
          • kubernetes 0.12

          My Jenkinsfile:

          podTemplate(label: 'slave', containers: [
              containerTemplate(name: 'docker', image: 'docker:dind', ttyEnabled: true, alwaysPullImage: true, privileged: true,
                command: 'dockerd --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 --storage-driver=overlay')
            ],
            volumes: [emptyDirVolume(memory: false, mountPath: '/var/lib/docker')]) {
          
            node('slave') {
            
              stage('Run a non-docker thing') {
                sh 'echo test'
                sh 'hostname -f'
                sh 'sleep 3'
              }
            
              stage('Run a docker thing') {
                container('docker') {
                  stage 'Docker thing1'
                  checkout scm
                  // sh 'docker info'
                  // sh 'docker build -t rmwpl/test:latest .'
                  // sh 'docker images'
                  app = docker.build("rmwpl/test:latest")
                  stage 'docker exec'
                  app.inside {
                    sh 'ls -alh'
                  }
                }
              }
            
            }
          
          }
          

          The error message:

          Removing intermediate container 8f6fa2e174e6
          Successfully built 238a4104c8fa
          Successfully tagged rmwpl/test:latest
          [Pipeline] dockerFingerprintFrom
          [Pipeline] }
          [Pipeline] // container
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] }
          [Pipeline] // podTemplate
          [Pipeline] End of Pipeline
          java.lang.IllegalArgumentException: Expecting 64-char full image ID, but got 
          	at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.getFingerprintHash(DockerFingerprints.java:71)
          	at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.forDockerInstance(DockerFingerprints.java:148)
          	at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.forImage(DockerFingerprints.java:115)
          	at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.forImage(DockerFingerprints.java:100)
          	at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.addFromFacet(DockerFingerprints.java:260)
          	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:119)
          	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:75)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
          	at hudson.security.ACL.impersonate(ACL.java:260)
          	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
          	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
          Finished: FAILURE
          

          I did some debugging with docker-commons and docker-workflow plugins (adding some custom log messages) and it looks like the stdout is not getting through from hudson.Launcher to docker-commons (as can be seen in the above stack trace, there isn't anything after "but got"). The same functionaliy (app = docker.build("whatever")) works when it isn't run from inside Kubernetes (via kubernetes-plugin).

          Actually, I've even modified the code launching appropriate "docker inspect" command in docker-workflow plugin to run "hostname" instead and its stdout is also not getting through to the calling process, so the problem does not seem to be related to dind in any way.

          Note that the commented-out code in my Jenkinsfile works fine, i.e. I'm able to build the image "by hand", but I'm aiming to use both the plugins (kubernetes-plugin and docker-workflow-plugin aka docker-pipeline-plugin) together.

          Right before the stacktrace, I was seeing the "SEVERE: onClose called but latch already finished. This indicates a bug in the kubernetes-plugin" message in the log, so I though it might be related to https://issues.jenkins-ci.org/browse/JENKINS-45885 and fixed in https://github.com/jenkinsci/kubernetes-plugin/pull/182, so I tried to use a snapshot built from master, but to no effect – stil getting the same stracktrace.

          I'm running the setup in minikube, if that matters in any way.

          Robert Wysocki added a comment - It looks like I'm being hit by the same bug. Using Jenkins 2.75 with the below plugins installed: docker commons 1.8 docker workflow (aka pipeline) 1.12 kubernetes 0.12 My Jenkinsfile: podTemplate(label: 'slave' , containers: [ containerTemplate(name: 'docker' , image: 'docker:dind' , ttyEnabled: true , alwaysPullImage: true , privileged: true , command: 'dockerd --host=unix: /// var /run/docker.sock --host=tcp://0.0.0.0:2375 --storage-driver=overlay' ) ], volumes: [emptyDirVolume(memory: false , mountPath: '/ var /lib/docker' )]) { node( 'slave' ) { stage( 'Run a non-docker thing' ) { sh 'echo test' sh 'hostname -f' sh 'sleep 3' } stage( 'Run a docker thing' ) { container( 'docker' ) { stage 'Docker thing1' checkout scm // sh 'docker info' // sh 'docker build -t rmwpl/test:latest .' // sh 'docker images' app = docker.build( "rmwpl/test:latest" ) stage 'docker exec' app.inside { sh 'ls -alh' } } } } } The error message: Removing intermediate container 8f6fa2e174e6 Successfully built 238a4104c8fa Successfully tagged rmwpl/test:latest [Pipeline] dockerFingerprintFrom [Pipeline] } [Pipeline] // container [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] } [Pipeline] // podTemplate [Pipeline] End of Pipeline java.lang.IllegalArgumentException: Expecting 64- char full image ID, but got at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.getFingerprintHash(DockerFingerprints.java:71) at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.forDockerInstance(DockerFingerprints.java:148) at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.forImage(DockerFingerprints.java:115) at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.forImage(DockerFingerprints.java:100) at org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints.addFromFacet(DockerFingerprints.java:260) at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:119) at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:75) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:260) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) Finished: FAILURE I did some debugging with docker-commons and docker-workflow plugins (adding some custom log messages) and it looks like the stdout is not getting through from hudson.Launcher to docker-commons (as can be seen in the above stack trace, there isn't anything after "but got"). The same functionaliy (app = docker.build("whatever")) works when it isn't run from inside Kubernetes (via kubernetes-plugin). Actually, I've even modified the code launching appropriate "docker inspect" command in docker-workflow plugin to run "hostname" instead and its stdout is also not getting through to the calling process, so the problem does not seem to be related to dind in any way. Note that the commented-out code in my Jenkinsfile works fine, i.e. I'm able to build the image "by hand", but I'm aiming to use both the plugins (kubernetes-plugin and docker-workflow-plugin aka docker-pipeline-plugin) together. Right before the stacktrace, I was seeing the "SEVERE: onClose called but latch already finished. This indicates a bug in the kubernetes-plugin" message in the log, so I though it might be related to https://issues.jenkins-ci.org/browse/JENKINS-45885 and fixed in https://github.com/jenkinsci/kubernetes-plugin/pull/182 , so I tried to use a snapshot built from master, but to no effect – stil getting the same stracktrace. I'm running the setup in minikube, if that matters in any way.

          Jesse Glick added a comment -

          rmwpl your exception looks unrelated, either in docker-commons or docker-workflow. Best to file it separately with complete steps to reproduce from scratch and just link it to this issue.

          Jesse Glick added a comment - rmwpl your exception looks unrelated, either in docker-commons or docker-workflow . Best to file it separately with complete steps to reproduce from scratch and just link it to this issue.

          Sure jglick, filed as JENKINS-46447

          Robert Wysocki added a comment - Sure jglick , filed as JENKINS-46447

          Just ran into this as well. Any of the command using "docker." don't seem to work. I had to revert to using "sh".

          Michael MacFadden added a comment - Just ran into this as well. Any of the command using "docker." don't seem to work. I had to revert to using "sh".

          Carlos Sanchez added a comment - This may be fixed with JENKINS-50392 https://github.com/jenkinsci/kubernetes-plugin/pull/300

          Can't reproduce with recent version.

          Vincent Latombe added a comment - Can't reproduce with recent version.

            iocanel Ioannis Canellos
            triplem Markus May
            Votes:
            6 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: