Creating a Jenkins configuration with Docker

591 views
Skip to first unread message

Matt Raible

unread,
Jul 25, 2017, 1:02:42 AM7/25/17
to JHipster dev team
Hey all,

I’m in the midst of updating the JHipster Mini Book for JHipster v4.

I tried running “yo jhipster:ci-cd” for my 21-points application. After checking in the generated files, I ran the Docker container for Jenkins.

docker-compose -f src/main/docker/jenkins.yml up -d

I installed the default set of plugins, and tried configuring an SCM Pipeline job. When it ran, I got the following error:

First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] sh
[21-points] Running shell script
+ docker inspect -f . openjdk:8
/var/jenkins_home/workspace/21-points@tmp/durable-a7a0be6d/script.sh: 2: /var/jenkins_home/workspace/21-points@tmp/durable-a7a0be6d/script.sh: docker: not found
[Pipeline] sh
[21-points] Running shell script
+ docker pull openjdk:8
/var/jenkins_home/workspace/21-points@tmp/durable-03fd168b/script.sh: 2: /var/jenkins_home/workspace/21-points@tmp/durable-03fd168b/script.sh: docker: not found
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE

I figured this might be caused by a missing Docker plugin, so I tried installing it in Jenkins. When it restarted, I couldn’t login with the password I created.

I tried blowing away the container and installing the Docker plugin before setting up my job. Same result.

Any ideas? Below is the result of “yo jhipster:info” from my project.

Thanks,

Matt

——
[mraible:~/dev/21-points] master ± yo jhipster:info | pbcopy
Welcome to the JHipster Information Sub-Generator

##### **JHipster Version(s)**

```
twenty-o...@0.0.0 /Users/mraible/dev/21-points
├── UNMET PEER DEPENDENCY @angular/com...@4.1.3
├── UNMET PEER DEPENDENCY @angular/co...@4.1.3
└── generator...@4.5.3

```


##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**

```yaml
{
"generator-jhipster": {
"promptValues": {
"packageName": "org.jhipster.health",
"nativeLanguage": "en"
},
"jhipsterVersion": "4.5.3",
"baseName": "TwentyOnePoints",
"packageName": "org.jhipster.health",
"packageFolder": "org/jhipster/health",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "ehcache",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "gradle",
"enableSocialSignIn": false,
"jwtSecretKey": "51b88e52708cfa62c9bc4a7e6c50eff6143ad55c",
"clientFramework": "angular2",
"useSass": true,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"testFrameworks": [
"gatling",
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"fr"
]
}
}
```


##### **Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

BloodPressure.json

```yaml
{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "many-to-one",
"otherEntityField": "login",
"ownerSide": true
}
],
"fields": [
{
"fieldName": "timestamp",
"fieldType": "ZonedDateTime",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "systolic",
"fieldType": "Integer",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "diastolic",
"fieldType": "Integer",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20160831021230",
"dto": "no",
"service": "no",
"entityTableName": "blood_pressure",
"pagination": "infinite-scroll"
}

```

Points.json

```yaml
{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "many-to-one",
"otherEntityField": "login",
"ownerSide": true
}
],
"fields": [
{
"fieldName": "date",
"fieldType": "LocalDate",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "exercise",
"fieldType": "Integer"
},
{
"fieldName": "meals",
"fieldType": "Integer"
},
{
"fieldName": "alcohol",
"fieldType": "Integer"
},
{
"fieldName": "notes",
"fieldType": "String",
"fieldValidateRules": [
"maxlength"
],
"fieldValidateRulesMaxlength": "140"
}
],
"changelogDate": "20170725030037",
"dto": "no",
"service": "no",
"entityTableName": "points",
"pagination": "pagination"
}

```

Preferences.json

```yaml
{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "one-to-one",
"otherEntityField": "login",
"ownerSide": true,
"otherEntityRelationshipName": "preferences"
}
],
"fields": [
{
"fieldName": "weekly_goal",
"fieldType": "Integer",
"fieldValidateRules": [
"required",
"min",
"max"
],
"fieldValidateRulesMin": "10",
"fieldValidateRulesMax": "21"
},
{
"fieldName": "weight_units",
"fieldType": "Units",
"fieldValues": "kg,lb",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20170725033721",
"dto": "no",
"service": "no",
"entityTableName": "preferences",
"pagination": "no"
}

```

Weight.json

```yaml
{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "many-to-one",
"otherEntityField": "login",
"ownerSide": true
}
],
"fields": [
{
"fieldName": "timestamp",
"fieldType": "ZonedDateTime",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "weight",
"fieldType": "Double",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20160831021351",
"dto": "no",
"service": "no",
"entityTableName": "weight",
"pagination": "infinite-scroll"
}

```


##### **Browsers and Operating System**

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

git version 2.12.2

node: v6.11.0

npm: 3.10.10

yeoman: 2.0.0

yarn: 0.24.4

Docker version 17.06.0-ce, build 02c1d87

docker-compose version 1.14.0, build c7bdf9e

Pascal GRIMAUD

unread,
Jul 25, 2017, 1:33:35 AM7/25/17
to Matt Raible, JHipster dev team
Hi Matt, 

You're trying to run Docker inside Docker ! In the jenkins.yml docker-compose file, you should have a comment part about that. Try to uncomment it. 
It works on Linux but never tried on Mac. 

For my demos, I always download jenkins.war and launch it. It's easier.  

Pascal

--
You received this message because you are subscribed to the Google Groups "JHipster dev team" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jhipster-dev+unsubscribe@googlegroups.com.
To post to this group, send email to jhipst...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jhipster-dev/1FB9484B-F7B2-4555-A13F-14C0F0BE9569%40raibledesigns.com.
For more options, visit https://groups.google.com/d/optout.

Julien Dubois

unread,
Jul 25, 2017, 1:35:22 AM7/25/17
to Grimaud Pascal, Matt Raible, JHipster dev team
Docker in Docker doesn't work on Mac (I run Docker in a JHipster devbox)

Pierre BESSON

unread,
Jul 25, 2017, 3:39:39 AM7/25/17
to Julien Dubois, Matt Raible, Pascal GRIMAUD, JHipster dev team
Hi Matt,

Actually this is not real "docker in docker", this is referred to as "docker outside of docker". You are simply sharing the docker socket of the host with a volume that you access from within the container. So using this methods all containers launched from within the container are simply run alongside the container from which they were started.

This setup usually work OK on Linux at least. Maybe try running the Jenkins 
docker—compose file in a separate VM (in the cloud or locally by using docker-machine) or simply use jenkins.war as suggested by Pascal.

Regards,
Pierre


Matt Raible

unread,
Jul 25, 2017, 1:16:17 PM7/25/17
to Pierre BESSON, Julien Dubois, Pascal GRIMAUD, JHipster dev team
Thanks all. 

I didn’t realize 1) jenkins.war was still the easiest thing to do and 2) you don’t have to select any options after you select the CI engine. 

One thing I did notice is that there is no stage for Protractor. Should we add one? Here’s what works for me.

    stage('protractor tests') {
        sh '''./gradlew &
        bootPid=$!
        sleep 60s
        yarn e2e
        kill $bootPid
        '''
    }

Cheers,

Matt

To unsubscribe from this group and stop receiving emails from it, send an email to jhipster-dev...@googlegroups.com.

To post to this group, send email to jhipst...@googlegroups.com.

Julien Dubois

unread,
Jul 25, 2017, 1:58:51 PM7/25/17
to Matt Raible, Pierre BESSON, JHipster dev team, Pascal GRIMAUD
Oh yes, but don't use the Jenkins installer : that runs with a specific "jenkins" user, but Docker for Mac can only work with the current user... So that would also fail.

Christophe Bornet

unread,
Jul 26, 2017, 5:39:37 PM7/26/17
to JHipster dev team
Hi Matt,

The problem with e2e tests is that you might need to launch a DB.
I had done a PoC but didn't do the integration by lack of time. See https://github.com/jhipster/generator-jhipster/issues/4693
I may work again on this when I come back from holidays.

Pierre BESSON

unread,
Jul 26, 2017, 6:12:32 PM7/26/17
to Christophe Bornet, JHipster dev team
This would be a good use case for testcontainers. Also we should use some script to wait for the app to start, for example the wait-for-it.sh script (https://github.com/vishnubob/wait-for-it) on /management/health.

--
You received this message because you are subscribed to the Google Groups "JHipster dev team" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jhipster-dev+unsubscribe@googlegroups.com.
To post to this group, send email to jhipst...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages