Skip to content

Conversation

@HQebupt
Copy link

@HQebupt HQebupt commented Aug 31, 2017

implement a shell script to publish docker .The input of the script: a tar package with all docker images. And implement a groovy script to call the shell script to publish docker to docker hub.

withCredentials([
usernamePassword(credentialsId: 'rackhd-ci-docker-hub',
passwordVariable: 'DOCKERHUB_PASS',
usernameVariable: 'DOCKERHUB_USER')]) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not used.
The user and password are passed by arguments

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. Thanks.

exit 1
fi
done
done < $DOCKER_RECORD_STASH_PATH

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tag info is the output of docker load
Could you please remove the parameter "DOCKER_RECORD_STASH_PATH"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. That means docker push command will push all repos in the docker tar file to the hub.docker.com

@HQebupt HQebupt force-pushed the feature/docker_publish branch 2 times, most recently from 8015124 to 8b69e32 Compare August 31, 2017 04:56
@HQebupt
Copy link
Author

HQebupt commented Aug 31, 2017

Done. @PengTian0 @panpan0000 @changev @HQebupt

:dockerhub_user: the rackhd user of dockerhub
:dockerhub_pass: the rackhd user password of dockerhub
*/
def publish(String library_dir, String docker_tar_path, String dockerhub_user, String dockerhub_pass) {
Copy link
Member

@changev changev Aug 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better to pass jenkins creds id and get creds info inside this function instead of passing user/password?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting to discuss.

Copy link

@panpan0000 panpan0000 Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with @HQebupt's implementation :-)
usability and flexibility , either way .

#
########################################################

main(){
Copy link
Member

@changev changev Aug 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommand to cut this main function into serval small functions, for example:

loadImages
push
clean

one method one function is easy to maintain, especially for next maintainers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

@HQebupt HQebupt force-pushed the feature/docker_publish branch from 8b69e32 to cca1750 Compare August 31, 2017 09:29
timeout(120){
sh """#!/bin/bash -ex
pushd $library_dir/src/pipeline/rackhd/docker
./publish.sh --DOCKER_STASH_PATH $docker_tar_path \
Copy link

@panpan0000 panpan0000 Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, do you need to run publish.sh with sudo ?
can you run docker operation without sudo in sandbox ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it works fine without sudo. :)

#!/bin/bash -e
# Environmental requirement:
# docker service running and docker have already logged with Rackhd Dockerhub ID,
# cmd 'docker login', if not logged then can't push images to dockerhub

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this comment still valid ? you have docker login in your code already

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful observation, I fixed it.

…nd a groovy script docker/Publish.groovy to publish docker.
@HQebupt HQebupt force-pushed the feature/docker_publish branch from cca1750 to 8a98932 Compare September 1, 2017 02:03
@changev
Copy link
Member

changev commented Sep 1, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants